我做一题,大家也做点吧。共享下?
#include <iostream>
#include <cstdlib>
using namespace std;
int number = 1;
int main()
{
char people[3][27];
int num[27];
int n;
int i , j;
cout << "please input n: ";
cin >> n;
while( n != 0 )
{
int flag = 0;
for( i = 0; i < 27; i++ )
num[i] = 0;
for( i = 0; i < 3; i ++ )
{
for( j = 0;j < n; j ++ )
{
cin >> people[i][j];
num[ people[i][j] - 'A' ]++;
}
}
cout << "Case # " << number << ": ";
for( i = 0; i < 27;i ++ )
{
if( num[i] == 3 )
{
cout << static_cast<char>( i + 'A' ) << "
";
flag = 1;
}
}
if( flag == 0 )
cout << "NO";
cout << endl;
number ++;
cout << "please input n: ";
cin >> n;
}
return 0;
}