Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
注意格式啊,每个图形完了要空一行!!贴代码!#include <iostream> #include <string> using namespace std; char ch[3][15]={"- -- -----"," ----- --","- -- -- --"}; char ch2[4][15]={"| ||| ||","||||| |||","| | | | ","|| |||||||"}; void caculate(char n[10],int p,int s); void sell(char n[10],int s,int p); int main() { int s,m=0; char n[10]; while(cin>>s>>n) { if(s == 0 && strcmp(n,"0")==0 ) break; for(int i = 0; i< 2*s+3 ;i++) { if(i==0) caculate(n,0,s); if(i==s+1) caculate(n,1,s); if(i==2*s+2) caculate(n,2,s); if(i>s+1&&i<2*s+2) sell(n,s,2); if(i<s+1&&i>0) sell(n,s,0); cout<<endl; } cout<<endl; } cout<<endl; return 0; } void caculate(char n[10],int p,int s) { for(int i = 0; i< strlen(n); i++) { cout<<" "; for(int j = 0; j < s; j++) cout<< ch[p][n[i]-'0']; cout<<" "; } } void sell(char n[10],int s,int p) { for(int i = 0; i< strlen(n); i++) { cout<<ch2[p][n[i]-'0']; for(int j= 0; j<s; j++) cout<<" "; cout<<ch2[p+1][n[i]-'0']<<" "; } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator