文章

19

粉丝

21

获赞

5

访问

19.0k

头像
暑假机试训练--Day5
综合
发布于2023年7月31日 08:26
阅读数 1.1k

字符串专题1(PAT):

1.A + B format

A+B format

 

2.Spell It Right

Spell It Right

 

3.Sign In and Sign Out

Sign In and Sign Out

 

4.Password

Password

 

5.Boys vs Girls

Boys vs Girls

 

6.String Subtraction

String Subtraction

 

7.Speech Patterns

Speech Patterns

 

8.Dating

Dating

 

9.Phone Bills

Phone Bills

 

10.Queueing at Bank

Queueing at Bank

 

AC代码:

1.A + B format

# include <bits/stdc++.h>
using namespace std;

string cal(int c){
  int k = c;

  if (c == 0) return "0";

  string ans;

  while (k){
    ans += (k % 10) + '0';
    k /= 10;
  }

  string res;

  for (int i = 0; i < ans.size(); ++i){
    res += ans[i];

    if (i % 3 == 2 && i != ans.size() - 1){
      res += ",";
    }
  }

  reverse(res.begin(),res.end());
  return res;

}
int main (void){
  int a,b;
  cin >> a >> b;

...
登录查看完整内容


登录后发布评论

暂无评论,来抢沙发