C/C++の宿題を片付けます 57代目
■ このスレッドは過去ログ倉庫に格納されています
0362デフォルトの名無しさん
2006/01/13(金) 17:19:39#include <stdio.h>
#include <string.h>
#define LEN 256
int main(){
char c, str[LEN];
int i, small, large, atom, ntoz, other;
small = large = atom = ntoz, other = 0;
printf("Input a string: ");
gets(str);
printf("The input string is \"");
for (i = 0; str[i] != '\0'; i++) {
if (islower(str[i]) != 0) small++;
else if (isupper(str[i]) != 0) large++;
c = tolower(str[i]);
if (('a' <= c) && (c <= 'm')) atom++;
else if (('n' <= c) && (c <= 'z')) ntoz++;
else other++;
printf("%c", str[i]);
}
puts("\".");
printf("# of letters = %d\n", i);
printf("# of small letters = %d\n", small);
printf("# of large letters = %d\n", large);
printf("# of A-M and a-m = %d\n", atom);
printf("# of N-Z and n-z = %d\n", ntoz);
printf("# of other letters = %d\n", other);
return 0;
}
■ このスレッドは過去ログ倉庫に格納されています