又一次可耻的用了STL 好像这个比之前那个更短 注:reverse函数在algorithm函数里 不是string或cstring里
#include <string> #include <algorithm> #include <iostream> using namespace std; string s; int main() { while( cin >> s ){ reverse(s.begin(),s.end()); cout << s << endl; } return 0; }
#include <iostream> using namespace std; int main() { int i, j, k, m, n; while( cin >> m >> n ){ while( m != n ){ if( m > n ) m -= n; else n -= m; } cout << m << endl; } return 0; }
#include <iostream> #include <fstream> using namespace std; int main() { int i, j, k, m, n; int a[11]; //a[0] abandoned //ifstream cin("HIT_1057.txt"); while( cin >> n ){ for( i=1; i<11; i++ ) a[i] = 0; a[n]++; for( i=2; i<21; i++ ){ cin >> n; a[n]++; } m = 1; for( i=2; i<11; i++ ) if( a[i] > a[m] ) m = i; cout << m << endl; } //system("pause"); return 0; }