Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: APNICHANAN

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

Language: c

Time: 0.002 second

Submitted On: 2025-09-25 10:30:15

#include <stdio.h>
#include <string.h>
int main()
{
    char s[20];
    scanf("%19s", &s);
    char sn[strlen(s)];
    char temp;
    int n = strlen(s);
    int c = 0;
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = 0; j < n - i - 1; j++)
        {
            if (s[j] > s[j + 1])
            {
                temp = s[j];
                s[j] = s[j + 1];
                s[j + 1] = temp;
            }
        }
    }
    // for (int i = 0; i < strlen(s); i++)
    //     printf("%d ", s[i]);

    for (int i = 0; i < strlen(s); i++)
    {
        c = 0;
        for (int j = 0; j < strlen(s); j++)
        {
            if (s[i] == s[j] && i != j)
            {
                c++;
            }
        }
        if (c == 0)
        {
            printf("%c", s[i]);
            break;
        }
    }
}