문자열에서 알파벳마다 각각 개수 출력
rank 구하기
gets() 와 scanf() 차이점
500자리 이상의 큰 수 비교
/*
#include <stdio.h>
#include <string.h>
int main()
{
char str[11];
int n, i;
scanf("%d", &n);
sprintf( str, "%d", n );
for(i = 0;i < strlen(str); ++i)
{
printf("%c", str[i]);
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
char str[11] = "1730000123";
int i, count[10] = {};
int max, maxi;
for(i = 0;i < 10;++i)
{
count[str[i] - '0']++;
printf("%d", str[i] - '0');
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
{
int i, cnt[27] = {0};
char str[] = "AbaDEFG123$#ABS WorLD";
for(i = 0; i < strlen(str) ; ++i)
{
if( isupper( str[i]) )
{
cnt[ str[i] - 'A']++;
}
}
for( i = 0; i < 26;i++)
{
printf("%c:%d\n", i + 'A', cnt[i]);
}
return 0;
}
*/
/* ���ڿ����� ���亪 ���� ���� ���
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
{
int i, cnt[27] = {};
char str[] = "AbaDEFG123$#ABS WorLD";
for(i = 0; i < strlen(str); i++)
{
if(isupper(str[i]))
{
cnt[str[i]-'A']++;
}
}
for(i = 0; i< 26; ++i)
{
printf("%c:%d\n", 'A' + i, cnt[i] );
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
{
int i ,cnt[27] ={};
char str[] = "AbaDEFG123$#ABS WorLD";
for( i = 0; i < strlen(str); ++i)
{
if( isupper(str[i] ))
{
cnt[str[i] - 'A']++;
}
}
for ( i = 0;i < 26;++i)
{
printf("%c:%d\n", 'A' + i, cnt[i] );
}
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
int a[10];
int i, n = 43, j;
for(i = 0; ;++i)
{
a[i] = n % 2;
n /= 2;
if(n == 0) {break;}
}
for( j = i; j >= 0;--j)
{
printf("%d", a[j]);
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
char str[11] = "101011";
int v = 0, i;
for(i = 0; i < strlen(str) ; ++i)
{
v = v * 2 + (str[i] - '0');
}
printf("%d", v);
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
char st1[] = "abcdef";
char st2[] = "Abcdef";
int c;
c = strcmp(st1, st2);
if( c == 0)
{
printf("same");
}
else
{
printf("Not same");
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
char st1[] = "World KOI";
char st2[20];
strcpy( st2, st1);
printf("%s %s", st1, st2 );
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
char st1[] = "abcdef";
char c = 'd';
char* p;
p = strchr( st1, c);
if( p != NULL)
{
printf("YES");
}
else
{
printf("NO");
}
return 0;
}
*/
/*
#include <stdio.h>
#include <stRing.h>
int main()
{
char st1[] = "abcdef";
char st2[] = "de";
char* p;
p = strstr( st1, st2);
if( p != NULL)
{
printf("YES");
}
else
{
printf("NO");
}
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
int i, cnt = 0;
char a[11];
gets(a);
for( i = 0 ; a[i] != NULL;++i)
{
++cnt;
}
printf("%d", cnt );
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
int i;
char str[21];
gets(str);
for( i = 0; str[i] != NULL ; ++i)
{
if( isdigit( str[i] ) == 1 )
{
printf("%c", str[i]);
}
}
return 0;
}
*/
/*
#include <stdio.h>
#include <ctype.h>
int main()
{
int i;
char str[101];
gets(str);
for( i = 0; i < strlen(str); ++i)
{
if( islower( str[i]) == 1)
{
printf("%c", str[i]);
}
}
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
int i;
char str1[11], str2[11] ;
gets(str1);
gets(str2);
if( strstr( str1, str2 ) != 0)
{
printf("YES");
}
else
{
printf("NO");
}
return 0;;
}
*/
/*
#include <stdio.h>
int main()
{
char a[11], b[11];
gets(a);
gets(b);
printf( "%d", strcmp(a, b));
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
int i, n;
scanf("%d", &n );
for( i = 1 ;i < strlen(n) ; i = n /10 )
{
n = n / 10;
}
}
*/
/*
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main()
{
char str[31];
int i;
gets(str);
for( i = 0 ; i < strlen(str); ++i)
{
if( isupper(str[i]) != 0 )
{
printf("%c", tolower(str[i]) );
}
else if( islower(str[i] != 0))
{
printf("%c", toupper(str[i]) );
}
else
{
printf("%c", str[i]);
}
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
int i;
int cnt1 = 0, cnt2 = 0;
char str[100];
gets(str);
for( i = 0; i < strlen(str) ; ++i)
{
if( str[i] == '[' )
{
++cnt1;
}
else if( str[i] == ']')
{
++cnt2;
}
}
printf("%d %d", cnt1, cnt2);
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
int i, j;
char str[3][10];
for(i = 0;i < 3;++i)
{
scanf("%s", str[i]);
}
for(i = 0; i < 3; ++i)
{
printf("%s\n", str[i]);
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
int i, j;
char str[5][101];
for(i = 0; i < 5; ++i)
{
scanf("%s", str[i] );
}
for (i = 0;i < 5; ++i)
{
if( strlen( str[i] ) <= 10 )
{
printf("%s\n", str[i] );
}
}
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
int i, j;
char name[][10]= { "minsu", "gunho", "sumin" };
for(i = 0; i < 3;++i)
{
printf("%s\n", name[i]);
}
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
int n = 5, i, j;
char name[][10] = { "minsu", "gunho" ,"sumin", "minho", "jihoon"};
int score[] = { 78, 64,84, 96, 55}, rank[10];
for(i = 0; i < n;++i)
{
rank[i] = 1;
}
for(i = 0;i < n;++i)
{
for(j = 0; j < n;++j)
{
if( score[i] < score[j] )
{
++rank[i];
}
}
}
for(i = 0; i < n; ++i)
{
if( rank[i] == 3)
{
printf("%s", name[i]);
}
}
*/
/* rank 3dnl ���ϱ�
#include <stdio.h>
int main()
{
int n = 5, i, j;
char name[][10] = { "minsu" , "gunho" ,"sumin", "minho" , "jihoon"};
int score[] = {78, 64, 84, 96, 55}, rank[10];
for(i = 0; i < n; ++i)
{
rank[i] = 1;
}
for(i = 0;i < n; ++i)
{
for(j =0; j < n;++j)
{
if (score[i] < score[j])
{
++rank[i];
}
}
}
for( i = 0;i < n ;++i)
{
if( rank[i] == 3)
{
printf("%s\n", name[i]);
}
}
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
int n = 5, i, j;
char name[][10] = { "minsu", "gunho" ,"sumin", "minho", "jihoon" };
int rank[10], score[] = { 78, 64, 85, 96, 55};
for( i = 0; i < n ;++i)
{
rank[i] = 1;
}
for( i =0; i < n; ++i)
{
for( j = 0; j < n; ++j)
{
if( score[i] < score[j] )
{
++rank[i];
}
}
}
for( i= 0;i < n;++i)
{
if( rank[i] == 3 )
{
printf("%s", name[i]);
}
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
char data[][10] = { "K.O.I", "# @ *" ,"WORLD" };
int main()
{
int i, j, k, l, len, w, h;
h =2; w =3;
for(i = 0; i < 3; ++i)
{
for(l = 0;l < h; ++l)
{
for(j =0; j <strlen(data[i]) ;++j )
{
for(k = 0;k < w;++k)
{
printf("%c", data[i][j] );
}
printf("\n");
}
}
}
printf("%d", strlen(data));
return 0;
}
*/
/* ���ڿ� ���ڸ��� 3��, 2���� �ݺ�
#include <stdio.h>
#include <string.h>
char data[][10] = { "K.O.I", "# @ *", "WORLD"};
int main()
{
int i, j, k, l, len, w, h;
len = strlen(data);
h = 2 , w = 3;
for(i = 0 ;i < 3 ;++i)
{
for(l = 0;l < h;++l)
{
for(j = 0; j < len; ++j)
{
for(k =0; k < w; ++k)
{
printf("%c", data[i][j]);
}
printf("\n");
}
}
}
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
int i, cnt = 0;
char str[100];
gets(str);
for( i = 0 ; str[i] != NULL; ++i )
{
++cnt;
}
printf("%d", cnt);
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
int i, len;
char str[100];
gets(str);
len = strlen(str);
printf("%c %c", str[0], str[len-1] );
return 0;
}
*/
/*
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main()
{
int i, len, sum = 0;
char str[100];
gets(str);
len = strlen(str);
for(i = 0; i < len; ++i)
{
if( isdigit(str[i]) != 0 )
{
sum = sum + str[i];
}
}
printf( "%d", sum );
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
int len, m = 0, i, a[26];
char c, s[26] = "no pain no gain";
for(i = 1;i < 26; ++i)
{
a[i] = 0;
}
len = strlen(a);
for( i = 0; i < len; ++i)
{
c = s[i] -'a' + 1;
if( 1 <= c && c <= 26)
{
++a[c];
}
}
for(i = 1; i <= 26 ; i++)
{
if( a[i] > m)
{
m = a[i];
}
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
char a[20] = "Korea\0Informatics\0";
printf("%s", a);
printf("%d", strlen(a) );
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
int i, j;
char a[20] = "Korea\0informatics\0";
int sum = 0;
for(i = 0; i < strlen(a) ; ++i)
{
sum += strlen(a);
char tmp = a[0];
for(j = 1;j < 18;++j)
{
a[j - 1]= a[j];
}
a[17] = tmp;
}
printf("%d", sum);
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
char a[100];
scanf("%s", a);
if( strstr(a, "tap") != '\0' )
{
printf("YES");
}
else
{
printf("NO");
}
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
char str[100];
scanf("%s", str);
printf("%s", str);
printf("END");
return 0;
}
*/
/* gets() �� scanf() �� ������
#include <stdio.h>
int main()
{
char str[100];
gets(str);
printf("%s", str);
printf("END");
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
char str[100];
gets(str);
puts(str);
printf("END");
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
char str[100];
gets(str +1);
puts(str);
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
{
char str[] = "ABCdef";
int i, len, k;
for(i =0; i< strlen(str) ;++i)
{
k = isupper( str[i] );
if ( k != 0)
{
printf("Large ");
}
k = islower(str[i]);
if( k != 0)
{
printf("Small");
}
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
{
char str[] = "ABC#def12~";
int i, len, k;
len = strlen(str);
for(i =0 ;i < len;++i)
{
k = isalpha(str[i]);
if( k != 0 )
{
printf("%c-Alphabet\n", str[i]);
}
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
{
char str[] = "ABCdef";
int i, len, k;
for(i =0;i < strlen(str);++i )
{
k = isupper(str[i]);
if( k != 0)
{
printf("%c", str[i] + 32);
}
k = islower(str[i]);
if( k != 0 )
{
printf("%c", str[i] - 32);
}
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
{
char str[] = "ABCdef";
int i, len, k;
for(i = 0;i < strlen(str); ++i)
{
if( 'A' <= str[i] && str[i] <= 'Z')
{
printf("%c", str[i] + 32);
}
else if( 'a' <= str[i] && str[i] <= 'z' )
{
printf("%c", str[i]);
}
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
{
char str[] = "ABCdef";
int i, len, k;
for(i = 0;i < strlen(str); ++i)
{
k = isupper(str[i]);
if( k != 0 )
{
printf("%c", tolower(str[i]));
}
k = islower(str[i]);
if( k != 0 )
{
printf("%c", toupper(str[i]));
}
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
{
char str[] = "A1B2C3d4E5f6";
int i, len, k;
for(i = 0;i < strlen(str) ; ++i)
{
k = isdigit(str[i]);
if(k != 0)
{
printf("%c", str[i]);
}
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
{
char str[] = "A1B2C3d4e5f6";
int i, len, k;
for(i = 0;i <strlen(str); ++i )
{
k = isdigit(str[i]);
if( !k )
{
printf("%c", str[i]);
}
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
char str[11];
int n = 1234567890;
sprintf( str, "%d", n);
printf("%s", str );
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
char str[11];
int n, i;
scanf("%d", &n);
sprintf(str, "%d", n );
for(i = 0; i< strlen(str) ; ++i)
{
printf("%c", str[i]);
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
char str[11] = "1730000123";
int i, count[10] = {};
int max, maxi;
for(i = 0; i < 10 ;++i)
{
++count[str[i]-'0'];
}
max = count[0];
maxi = 0;
for(i = 1;i < 10;++i)
{
if( count[i] > max )
{
max = count[i];
maxi = i;
}
}
printf("%d %d", maxi, max);
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
int i;
char str[31];
gets(str);
for( i = 0; i < strlen(str); ++i)
{
if( isupper( str[i] ) )
{
printf("%c", tolower(str[i]));
}
else if( islower(str[i]) )
{
printf("%c", toupper(str[i]) );
}
else
{
printf("%c", str[i]);
}
}
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
int sum = 0, i, n1;
int n[100];
scanf( "%d", n);
for( i = 0; ;++i)
{
n1 = n % 10;
sum = sum + n1;
n = n / 10;
if( n == 0)
{
break;
}
}
printf("%d", sum);
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
int len1, len2, len3;
char S1[21], S2[21], S3[21];
gets(S1);
gets(S2);
gets(S3);
len1 = strlen(S1);
len2 = strlen(S2);
len3 = strlen(S3);
if( S1[0] == S3[len3 - 1] &&
S2[0] == S1[len1 - 1] &&
S3[0] == S2[len2 - 1]
)
{
printf("good");
}
else
{
printf("bad");
}
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
long int n;
scanf("%lld", &n);
if( n % 3 == 0)
{
printf("1");
}
else
{
printf("0");
}
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
int i;
char str[30];
gets(str);
printf("welcome! %s", str);
return 0;
}
*/
/* IOI ����
#include <stdio.h>
int main()
{
char str[30];
gets(str);
if( str == 'IOI')
{
printf("IOI is the International Olympiad in Informatics");
}
else
{
printf("I don't care.");
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
int i;
char str[11];
gets(str);
for(i = 0; i < strlen(str); ++i )
{
if( str[i] == 't')
{
printf("%d ", i + 1);
}
}
return 0;
}
*/
/* 1414�� ����
#include <stdio.h>
int main()
{
int i;
char str[100];
gets(str);
if( i = 0; i < strlen(str); ++i)
{
if( )
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
int i, cnt1 = 0, cnt2 = 0;
char str[1000000]={};
gets(str);
for(i = 0; i < strlen(str); ++i )
{
if( str[i] == '(' )
{
++cnt1;
}
else if( str[i] == ')' )
{
++cnt2;
}
}
printf("%d %d", cnt1, cnt2);
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
int i;
char str[21];
gets(str);
for( i = 0; i < strlen(str); ++i)
{
printf("%c" , str[i] + 2);
}
printf("\n");
for( i = 0; i < strlen(str); ++i)
{
printf("%c" , ( str[i] * 7 ) % 80 + 48);
}
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
char str[31];
gets(str);
printf("%s", str);
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
char str[10];
gets(str);
if( strcmp( str, "love" ) == 0)
{
printf("I love you.");
}
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
char str[10];
gets(str);
puts(str);
return 0;
}
*/
/*
#include <stdio.h>
int main()
{
char c;
scanf("%c", &c);
printf("%c", c);
return 0;
}
*/
/* 500�ڸ� �̻� �� 3�� ��� �Ǻ�
#include <stdio.h>
#include <string.h>
int main()
{
int i, cnt = 0;
char str[501];
gets(str);
for( i = 0; i < strlen(str); ++i)
{
cnt = cnt + str[i];
}
if( cnt % 3 == 0)
{
printf("1");
}
else
{
printf("0");
}
return 0;
}
*/
/* 1754�� ����
#include <stdio.h>
#include <string.h>
int main()
{
char str1[101], str2[101];
int i;
scanf("%s %s", str1, str2);
if ( strlen(str1) > strlen(str2) )
{
printf("%s %s", str2, str1 );
}
else if ( strlen(str1) < strlen(str2) )
{
printf("%s %s", str1, str2 );
}
else
{
for(i = strlen(str1) - 1; i >= 0 ; --i)
{
if( str1[i] < str2[i])
{
printf( "%s %s", str1, str2);
break;
}
else if (str1[i] > str2[i] )
{
printf("%s %s", str2, str1);
break;
}
}
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
char str[100], ans[4] = "IOI";
gets(str);
if( strcmp( str, ans ) == 0 )
{
printf("IOI is the International Olympiad in Informatics.");
}
else
{
printf("I don't care.");
}
return 0;
}
*/
/* 100�ڸ� ū �� ��
#include <stdio.h>
#include <string.h>
int main()
{
int i, len1, len2;
char str1[101], str2[101];
scanf("%s %s", str1, str2 );
len1 = strlen(str1);
len2 = strlen(str2);
if( len1 > len2 )
{
printf("%s %s", str2, str1);
}
else if( len1 < len2 )
{
printf("%s %s", str1, str2);
}
else
{
for ( i = 0; i < len1 ; ++i)
{
if( str1[i] > str2[i] )
{
printf("%s %s", str2, str1 );
break;
}
else if ( str1[i] < str2[i] )
{
printf("%s %s", str1, str2 );
break;
}
}
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
int i, cnt = 0, len;
char str[101];
gets(str);
len = strlen(str);
for( i = 0; i < len;++i)
{
if( strchr( str, 'c') != 0 )
{
printf("%d", i );
}
}
return 0;
}
*/
/*
#include <stdio.h>
#include <string.h>
int main()
{
char str1[100], str2 = "love";
int i, len, cnt = 0;
len = strlen(str1);
gets(str1);
for( i = 0;i < strlen(str1); ++i)
{
if (strstr( str1, str2) != NULL )
{
cnt++;
}
}
printf("%d", cnt);
return 0;
}
*/
'컴퓨터 과학 > C Language' 카테고리의 다른 글
2022-01-23 포인터 변수 (0) | 2022.01.24 |
---|---|
2022-01-21 문자열 연습 (0) | 2022.01.22 |
2022-01-19 문자열 (0) | 2022.01.19 |
2022-01-18 함수 만들기 (0) | 2022.01.19 |
2022-01-17 2차원 배열 연습 (0) | 2022.01.18 |