文章

19

粉丝

21

获赞

5

访问

13.1k

头像
暑假机试训练--Day4
综合
发布于2023年7月30日 19:50
阅读数 644

武汉大学2018机试题:

1.输出图形

A.输出图形

 

2.大整数加法

B.大整数加法

 

3.回文质数

C.回文质数

 

4.数字计数

D.数字计数

 

AC代码:

A.输出图形

// 输出格式一定要注意,太坑了!
# include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N];

void print(int x){
  if (x < 10) cout << x << "   ";
  else if (x >= 10 && x < 100) cout << x << "  ";
  else if (x > 100) cout << x << " ";
}
int main (void){
  int n;
  cin >> n;
  
  int idx = 1;
  for (int i = 1; i <= n; ++i){
    for (int j = 1; j <= i; ++j){
      if (j == i){
        cout << idx;
      }else{
        print(idx);
      }
      idx ++;
    }
    cout << endl;
  }
  
  return 0;
}

 

B.大整数加法

// 高精度模板题
# include <bits/stdc++.h>
using namespace std;

string Add(string a,string b){
  int t = 0;
  string ans;
  
  for (int i = a.size() - 1,j = b.size() - 1; i >= 0 || ...
登录查看完整内容


登录后发布评论

暂无评论,来抢沙发