鱼塘溺水 @ 2017-02-13 18:02:05
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char con[30][15] = { "one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty" };
int main()
{
char temp[8][15];
char code[8][5];
char str[10];
int data[8];
int i, j, k, m, n, count = 1, flag = 0;
for (i = 1; i <= 7; i++) scanf("%s", temp[i]);
for (i = 1; i <= 6; i++)
{
if (!strcmp(temp[i], "a") || !strcmp(temp[i], "another") || !strcmp(temp[i], "first"))
{
data[count++] = 1;
continue;
}
if (!strcmp(temp[i], "both") || !strcmp(temp[i], "second"))
{
data[count++] = 2;
continue;
}
if (!strcmp(temp[i], "third"))
{
data[count++] = 3;
continue;
}
for (j = 0; j < 20; j++)
{
if (!strcmp(temp[i], con[j]))
{
data[count++] = j + 1;
break;
}
}
}
count--;
for (i = 1; i <= count; i++)
{
k = (data[i] * data[i]) % 100;
if (k < 10)
{
code[i][0] = '0';
code[i][1] = k + '0';
}
else
{
code[i][0] = k / 10 + '0';
code[i][1] = (k - 10*(k / 10)) + '0';
}
code[i][2] = '\0';
}
for(i=1;i<=count;i++)
for (j = 1; j <= count - i + 1; j++)
{
if (strcmp(code[i], code[i + 1]) > 0)
{
strcpy(str, code[i]);
strcpy(code[i], code[i + 1]);
strcpy(code[i + 1], str);
}
}
for (i = 1; i <= count; i++)
{
if (!flag)
{
for (j = 0; j < 2; j++)
{
if (code[i][j] != '0')
{
if (j == 0)
{
printf("%s", code[i]);
flag = 1;
break;
}
else
{
printf("%c", code[i][j]);
flag = 1;
break;
}
}
}
}
else printf("%s", code[i]);
}
if (!flag) printf("0");
}
下载了测试数据自己测试,觉得没问题的啊
by 中2少年雷耶斯 @ 2017-02-13 19:08:07
格式有问题
by 鱼塘溺水 @ 2017-02-14 08:15:48
那是什么问题?