標籤:
題目串連:點擊開啟連結
解題思路:
類比
完整代碼:
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <set>using namespace std;const int INF = 1000000000;const int maxn = 10001; char a[maxn] , b[maxn];void MyStrcat(char dstStr[] , char srcStr[]){ char c[maxn]; int cnt = 0; for(int i = 0 ; dstStr[i] ; i ++) c[cnt++] = dstStr[i]; for(int i = 0 ; srcStr[i] ; i ++) c[cnt++] = srcStr[i]; c[cnt++] = '\0'; for(int i = 0 ; c[i] ; i ++) printf("%c" , c[i]); cout << endl;} int main(){ #ifdef DoubleQ freopen("in.txt" , "r" , stdin); #endif // DoubleQ while(cin >> a >> b) { MyStrcat(a , b); }}
題目串連:點擊開啟連結
解題思路:
此題完全可以增加難度的,而且感覺題意表述有問題,陌生人向富翁談計劃,那第一句口吻應該是陌生人說的。。。。可是最後確是以富翁口吻來解題。
完整代碼:
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <set>using namespace std;const int INF = 1000000000;const int maxn = 10001; int main(){ long long sum = 1; long long k = 1; for(int i = 2 ; i <= 30 ; i ++) { k = k * 2; sum += k; } cout << "300 " << sum << endl;}
題目串連:點擊開啟連結
解題思路:
這道題讓我明白了九度上面時要用迴圈判斷是否輸入結尾才終止!!!
完整代碼:
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>#include <set>using namespace std;const int INF = 1000000000;const int maxn = 10001; long long a[4][4] , b[4][4];long long c[4][4];int main(){ #ifdef DoubleQ freopen("in.txt" , "r" , stdin); #endif // DoubleQ while(cin >> a[0][0]) { cin >> a[0][1] >> a[0][2] >> a[1][0] >> a[1][1] >> a[1][2]; for(int i = 0 ; i < 3 ; i ++) { for(int j = 0 ; j < 2 ; j ++) { cin >> b[i][j]; } } for(int i = 0 ; i < 2 ; i ++) { for(int j = 0 ; j < 2 ; j ++) { long long sum = 0; for(int k = 0 ; k < 3 ; k ++) { sum += a[i][k] * b[k][j]; } c[i][j] = sum; } } for(int i = 0 ; i < 2 ; i ++) { for(int j = 0 ; j < 2 ; j ++) { cout << c[i][j] << " "; } cout << endl; } }}
2012年哈爾濱工業大學電腦研究生機試真題