Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: emipp

Problemset: ตัวอักษรตัวแรกในคำ

Language: cpp

Time: 0.002 second

Submitted On: 2025-10-12 11:50:30

#include<iostream>
#include<string.h>
using namespace std ; 
int main () {
    char name [21] ;
    cin >> name ;
    int y = strlen(name) ;
    int min = 0 ;
    for (int j = 0 ; j <y ; j++) {
        if (name[j] >= 65 && name[j] <= 90 )
continue ;
else {
    return 0 ;
}
    }
    for (int i = 0 ; i <y-1 ; i++  ) {
        for (int j = 0 ; j < y-1-i ; j++ ){
                if(name[j] > name[j+1])
                swap(name[j],name[j+1]);
        }
    }
    
   
   if ( name[0] != name[1] ) {
    cout << name [0] ;
   }
   if (name[0] == name[1]){
        for (int j = 2 ; j <y ; j++){
             if (name[j-1] != name[j] && name[j] != name[j+1]){
                cout << name[j] ;
            return 0;}
                
        }
    }
return 0 ;
}