Advertisement

2012年哈尔滨工业大学计算机研究生机试真题

阅读量:

题目连接:点击打开链接

解题思路:

模拟

完整代码:

复制代码
 #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;
    
     }
    
     }
    
 }
    
    
    
    
    代码解释

全部评论 (0)

还没有任何评论哟~