#include <stdio.h>
#include <ctype.h>
int main( void )
{
int ch, i;
int alpcnt[26] = {0}; /* アルファベットカウンタを 0クリア */
/*** 文字を入力し、入力英字の個数を数える ***/
printf( "文字を入力しなさい(終了条件:Ctrl+Z)\n" );
while ( ( ch = getchar( ) ) != EOF ) {
if ( isupper( ch ) != 0 ) {
alpcnt[ch-'A']++;
}
else if ( islower( ch ) != 0 ) {
alpcnt[ch-'a']++;
}
}
/*** 英字の入力個数を出力 ***/
for ( i = 0;i < 26; i++ ) {
printf( "%c : %3d個入力\t\t", 'a'+i, alpcnt[i] );
if ( i%3 == 2 )
putchar( '\n' );
}
return 0;
}
※Windows9xとMe上で、Windows系のCを用いて「CTRL+Z」の入力を実行した場合、
「CTRL+Z」の入力後、次の改行までの表示が行なわれません。(2002.06.11 追記)
▼戻る▼
「初心者のためのポイント学習C言語」 Copyright(c) 2000-2004 TOMOJI All Rights Reserved