- 39 名前:デフォルトの名無しさん mailto:sage [2007/11/06(火) 21:41:39 ]
- // >>32 文中のaの数をカウントするプログラム
// bcc 5.5.1 for win32 #include <iostream.h> int main(void) { const int Max_Length = 50 ; // 入力文字列の最大値 char sentence[Max_Length] , dummy[Max_Length]; // 入力文字列 int count = 0, a = 0; // 文字カウンタ // 文字列の入力 cout << "英数字のみの文字列を入力して下さい。 >>> " ; cin.getline( sentence, Max_Length ) ; // 文字数のカウント while( sentence[count] != '\0'){ if (sentence[count] == 0x61){ a++ ; dummy[count] = '^' ; } else { dummy[count] = ' ' ; } count++ ; } dummy[count] = '\0' ; cout << "aは次の数だけ見つかりました : " << a << "\n" << sentence << "\n" << dummy << endl ; }
|

|