题目:http://poj.org/problem?id=3765
这个题目是我们一次比赛的题目,看着挺简单的,呵呵,只要你看懂题目就行了,废话不多说。
代码贴上,大家参考下,不懂给我留言。欢迎交流!
#include<string>
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
string str[23];
str[0]= " _";
str[1]= " _/ \\_";
str[2]= " _/ \\_/ \\_";
str[3]= " _/ \\_/ \\_/ \\_";
str[4]= " _/ \\_/ \\_/ \\_/ \\_";
str[5]= "/ \\_/ \\_/ \\_/ \\_/ \\";
str[6]= "\\_/ \\_/ \\_/ \\_/ \\_/";
str[7]= "/ \\_/ \\_/ \\_/ \\_/ \\";
str[8]= "\\_/ \\_/ \\_/ \\_/ \\_/";
str[9]= "/ \\_/ \\_/ \\_/ \\_/ \\";
str[10]="\\_/ \\_/ \\_/ \\_/ \\_/";
str[11]="/ \\_/ \\_/ \\_/ \\_/ \\";
str[12]="\\_/ \\_/ \\_/ \\_/ \\_/";
str[13]="/ \\_/ \\_/ \\_/ \\_/ \\";
str[14]="\\_/ \\_/ \\_/ \\_/ \\_/";
str[15]="/ \\_/ \\_/ \\_/ \\_/ \\";
str[16]="\\_/ \\_/ \\_/ \\_/ \\_/";
str[17]="/ \\_/ \\_/ \\_/ \\_/ \\";
str[18]="\\_/ \\_/ \\_/ \\_/ \\_/";
str[19]=" \\_/ \\_/ \\_/ \\_/";
str[20]=" \\_/ \\_/ \\_/";
str[21]=" \\_/ \\_/";
str[22]=" \\_/";
int t[20]={4,3,2,1,0,1,2,3,4};
string s[23];
int i,k,n;
char j,ch;
while(scanf("%d",&n)!=EOF&&n)
{
getchar();
for(i=0;i<23;i++)
s[i]=str[i];
while(n--)
{
cin>>j>>i>>ch;
k=j%65;
s[23-t[k]-2*(i+1)][(int)j%65*2+1]=ch;
}
for(i=0;i<23;i++)
cout<<s[i]<<endl;
}
return 0;
}
中间我们创建数组的时候忘了 \ 这个符号不能直接存,导致郁闷了半天,嘿嘿,后来终于发现存的时候有点问题。 下面的操作感觉还可以,看一下,自己模拟一下就能懂了。