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 |
先把input的字符串存入一个二维数组,然后再输出~~晕,可是怎么会错了呢?请大侠指点一下啊(附代码)#include<iostream.h> #include<string.h> #include <stdio.h> #include<math.h> int main() { int i,j,k,n,row,col; char s1[201]; char s2[21][21]; while(cin>>col) { if(col==0) break; gets(s1); n=strlen(s1); row=n/col; for(i=0;i<row;i++) { if(i%2==0) { j=0; while(j<col) { for(k=i*col;k<(i+1)*col;k++) { s2[i][j]=s1[k]; j++; } } } else { j=0; while(j<col) { for( k=((i+1)*col-1) ; k>=i*col; k--) { s2[i][j]=s1[k]; j++; } } } } for(j=0;j<col;j++) { for(i=0;i<row;i++) { cout<<s2[i][j]; } } cout<<endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator