PAT乙题1006. 换个格式输出整数 (15)

2018/01/25 PAT 共 774 字,约 3 分钟
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<map>
#include<string>
#include<fstream>
#include<vector>
#include<functional>
using namespace std;
int main() {
#ifdef LOCAL
	freopen("d:\\datain.txt", "r", stdin);
	freopen("d:\\dataout.txt", "w", stdout);
#endif LOCAL
	char p[4];
	scanf("%s", p);
	int n = strlen(p);
	if (n == 3) {
		int a = p[0] - '0';
		int b = p[1] - '0';
		int c = p[2] - '0';
		for(int j=0;j<a;j++)
			cout << "B";
		for (int j = 0; j < b; j++)
			cout << "S";
		for (int j = 1; j <= c; j++)
			cout << j;
		
	}
	if (n == 2) {
		int a = p[0] - '0';
		int b = p[1] - '0';
		for (int j = 0; j<a; j++)
			cout << "S";
		for (int j = 1; j <= b; j++)
			cout << j;
	}
	if (n == 1) {
		int a = p[0] - '0';
		for (int j = 1; j <= a; j++)
			cout << j;
	}
	return 0;
}

Search

    Table of Contents