poj1750

简单题

注意有两个相同单词相邻的情况

View Code
#include <iostream>
#include
<cstdio>
#include
<cstdlib>
#include
<cstring>
using namespace std;

#define maxl 20

char st[2][maxl];

int main()
{
//freopen("t.txt", "r", stdin);
int sum = 0;
int i = 0;
st[
1][0] = '\0';
while (scanf("%s", st[i]) != EOF)
{
int same = 0;
for (int j = 0; j < sum + 1; j++)
if (st[i][j] == st[i ^ 1][j] && st[i][j] != 0)
same
++;
else
break;
if (same == sum + 1)
sum
++;
else
sum
= same;
for (int j = 0; j < sum; j++)
putchar(
' ');
printf(
"%s\n", st[i]);
i
^= 1;
}
return 0;
}

你可能感兴趣的:(poj)