您的位置:首页 > 其它

uva10361--String

2011-12-08 21:10 246 查看
字符串类型的水题

//#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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: