字符串类型的水题
//#define LOCAL #include <stdio.h> #include <string.h> #define MAXN 100 + 10 char s1[MAXN], s2[MAXN], s3[MAXN], s4[MAXN], s5[MAXN]; char buf[MAXN]; int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); #endif int cases; char c; int i, j; scanf("%d", &cases); c = getchar();// 消除数字后面的回车 while(cases--) { // 数据初始化 memset(s1, 0, sizeof(s1)); memset(s2, 0, sizeof(s2)); memset(s3, 0, sizeof(s3)); memset(s4, 0, sizeof(s4)); memset(s5, 0, sizeof(s5)); memset(buf, 0, sizeof(buf)); // 数据输入 // 输入s1 c = getchar(); for(i = 0;c != '<';i++) { s1[i] = c; c = getchar(); } // 输入s2 c = getchar(); for(i = 0;c != '>';i++) { s2[i] = c; c = getchar(); } // 输入s3 c = getchar(); for(i = 0;c != '<';i++) { s3[i] = c; c = getchar(); } // 输入s4 c = getchar(); for(i = 0; c != '>';i++) { s4[i] = c; c = getchar(); } // 输入s5 c = getchar(); for(i = 0; c != '\n';i++) { s5[i] = c; c = getchar(); } // 输入buf c = getchar(); for(i = 0; c != '.';i++) { buf[i] = c; c = getchar(); } c = getchar(); c = getchar(); c = getchar(); // 消除两个点和一个换行 // 数据输出 printf("%s%s%s%s%s\n", s1, s2, s3, s4, s5); printf("%s%s%s%s%s\n", buf, s4, s3, s2, s5); } return 0; }uva10361--String
最新推荐文章于 2016-07-18 14:59:43 发布
本文详细解析了如何通过输入和输出字符串数据来解决特定类型的编程问题,包括数据的初始化、输入与输出操作。
596

被折叠的 条评论
为什么被折叠?



