思路:
首先读取第一个表示颜色的字符串保存为结构体数组的第一个元素,个数为 1,结构体元素数个为1
然后每读取一个颜色字符串,就到结构体数组中寻找相同的字符串,如果找到,个数加1
如果没找到,在结构体中添加一个元素,个数为1,结构体元素个数加1
最后以结构体元素个数为标记,循环查找个数最大的一个元素,输出
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define LEN 20
struct color{
s...
/*Z -> A */
#include <stdio.h>
#include <strings.h> /*某些编译器为: <string.h>*/
int main(void)
{
char ch[51];
int line, k, i = 1;
scanf("%d", &line);
while(line--)
{
scanf("%s", ch);
printf("String #%d\n", i++);
for(k = 0; k < s...
#include <stdio.h>
#include <math.h>
int main(void)
{
int line, num, band, sum, i;
char ch_l, ch_r;
while(scanf("%d", &line) != EOF)
{
if(line == 0) break;
sum = 0;
while(line--)
{
i = 0;
scanf("%d%c%d%...
/*输入的第一行是一个整数,测试的数目。
*在每一行输入一个数字m,计算m^m 的最后一位
*/
#include <stdio.h>
int main(void)
{
int line, number, last, tmp;
scanf("%d", &line);
while(line--)
{
last = 1;
scanf("%d", &number);
tmp = number % 10;
switch(tmp)
...
#include <stdio.h>
int main(void)
{
int line, no_advertise, do_advertise, cost;
scanf("%d", &line);
while(line--)
{
int tmp;
scanf("%d %d %d", &no_advertise, &do_advertise, &cost);
tmp = do_advertise - cost - no_advertise;
...
/* 输入12行浮点数,计算平均数,保留2位小数*/
#include <stdio.h>
#define MONTH 12
int main(void)
{
int month = MONTH;
float balance, tmp = 0;
while(month--)
{
scanf("%f", &balance);
tmp += balance;
}
printf("$%.2f\n", tmp / MONTH);
return 0;
}
#include <stdio.h>
int main(void)
{
int n, m, tmp;
while(scanf("%d %d", &n, &m) == 2)
{
if(n == -1 && m == -1)
break;
while(m != 0)
{
tmp = n % m;
n = m;
m = tmp;
}
...
#include <stdio.h>
int main(void)
{
int s, n, tmp, sum;
scanf("%d", &n);
while(n-- && (scanf("%d", &s) == 1))
{
sum = 0;
while(s--)
{
scanf("%d", &tmp);
sum += tmp;
...
#include <stdio.h>
int main(void)
{
int a, b;
while((scanf("%d %d", &a, &b) != EOF))
{
printf("%d\n", a + b);
printf("\n");
}
return 0;
}
#include <stdio.h>
int main(void)
{
int n, tmp, sum;
while((scanf("%d", &n) != EOF))
{
sum = 0;
while(n--)
{
scanf("%d", &tmp);
sum += tmp;
}
printf("%d\n", sum);
}
return 0;
}
#include <stdio.h>
int main(void)
{
int s, n, tmp, sum;
scanf("%d", &n);
while(n-- && (scanf("%d", &s) == 1))
{
sum = 0;
while(s--)
{
scanf("%d", &tmp);
sum += tmp;
...
#include <stdio.h>
int main(void)
{
int n, tmp, sum;
while((scanf("%d", &n) == 1) && n != 0)
{
sum = 0;
while(n--)
{
scanf("%d", &tmp);
sum += tmp;
}
printf("%d\n", sum);
}
return 0...
/* a+b
* 输入0 0 结束程序
*/
#include <stdio.h>
int main(void)
{
int a, b;
while((scanf("%d %d", &a, &b)) && a + b != 0)
printf("%d\n", a + b);
return 0;
}
/*计算a + b
* 输入包含一个整数N在第一行,然后N行跟进。
* 每行包含一个整数对A和B,用空格隔开,每行一个整数对。
*/
#include <stdio.h>
int main(void)
{
int a, b, n;
scanf("%d", &n);
while(n > 0)
{
scanf("%d %d", &a, &b);
printf("%d\n", a + b);
n--;
}
return 0;
...
#include <stdio.h>
int main(void)
{
int a, b;
while((scanf("%d %d", &a, &b) != EOF))
printf("%d\n", a + b);
return 0;
}