UVa 11734 - Big Number of Teams will Solve This

Contents

  1. 1. Problem
  2. 2. Solution
  3. 3. Code

Problem

中文網址

Solution

如下~

Code

UVa 11734
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<cstdio>
#include<cstring>

int main()
{
int Case;
char str1[100], str2[100];
scanf("%d", &Case);
getchar();
for (int c = 1; c <= Case; c++)
{
fgets(str1, 100, stdin);
fgets(str2, 100, stdin);
int i, j, len1 = strlen(str1) - 1;
bool wrong = false, format = true;
for (i = 0, j = 0; i < len1; i++)
if (str1[i] == str2[j])
j++;
else if (str2[j] == ' ')
{
j++;
i--;
wrong = true;
}
else if (str1[i] != ' ')
{
format = false;
wrong = true;
break;
}
else//str1[i]==' '
wrong = true;

printf("Case %d: ", c);
if (!wrong)
puts("Yes");
else if (format&&j == strlen(str2) - 1)
puts("Output Format Error");
else
puts("Wrong Answer");
}

return 0;
}