字符串处理 BestCoder Round #43 1001 pog loves szh I

 

题目传送门

 1 /*  2  字符串处理:是一道水题,但是WA了3次,要注意是没有加'\0'的字符串不要用%s输出,否则在多组测试时输出多余的字符  3 */  4 #include <cstdio>  5 #include <algorithm>  6 #include <cstring>  7 #include <cmath>  8 using namespace std;  9 10 typedef long long ll; 11 const int MAXN = 1e2 + 10; 12 const int INF = 0x3f3f3f3f; 13 char ss[MAXN]; 14 char s[MAXN], t[MAXN]; 15 16 int main(void) //BestCoder Round #43 1001 pog loves szh I 17 { 18 // freopen ("A.in", "r", stdin); 19 20 int tt; scanf ("%d", &tt); 21 while (tt--) 22  { 23 scanf ("%s", ss + 1); 24 // printf ("%s\n", ss + 1); 25 int len = strlen (ss + 1); 26 // printf ("%s\n", ss + 1); continue; 27 int p1 = 0, p2 = 0; 28 for (int i=1; i<=len; ++i) 29  { 30 if (i & 1) s[++p1] = ss[i]; 31 else t[++p2] = ss[i]; 32  } 33 34 for (int i=1; i<=p1; ++i) printf ("%c", s[i]); 35 puts (""); 36 for (int i=p2; i>=1; --i) printf ("%c", t[i]); 37 puts (""); 38 39 // if (tt) puts (""); 40  } 41 42 return 0; 43 }

 

你可能感兴趣的:(round)