问题描述
问题分析
题目不难
自认为巧妙的一点是用字符串储存了对应关系
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| #include<stdio.h>
#include<string.h>
int main() {
char word[]= {"OOTTFFSSEN"};
int T;
scanf("%d",&T);
while(T--) {
char s[15];
scanf("%s",s);
for(int i=strlen(s)-1; i>=0; i--) {
printf("%c",word[s[i]-'0']);
}
printf("\n");
}
return 0;
}
|
标程还是使用数字来储存的输入数据
然后puts("");
用来输出换行
(……虽然现在不知道为什么能这样)
思路还是一样的
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| #include<cstdio>
char str[]="OOTTFFSSENT";
void show(int t) {
if(t) {
putchar(*(str+t%10));
show(t/10);
}
}
int main() {
int n,t;
scanf("%d",&t);
while(t--) {
scanf("%d",&n);
show(n);
puts("");
}
}
|