/* 修正版 */
#include <stdio.h>
#include <string.h>
struct person
{
char name[30];
int count;
} leader[3] = {{"lilin", 0}, {"zhangwen", 0}, {"dacong", 0}};
int main(void)
{
int i;
char namel[10];
for(i = 0; i < 3; i++)
{
scanf("%29s",namel); /* 因为数组名就是地址 */
if(strcmp(namel, leader[i].name) == 0)
leader[i].count++;
}
printf("\n");
for(i = 0; i < 3; i++)
{
printf("%5s, %5d\n", leader[i].name, leader[i].count);
}
while(getchar() != '\n');
getchar();
return 0;
}
#include <stdio.h>
#include <string.h>
struct person
{
char name[30];
int count;
} leader[3] = {{"lilin", 0}, {"zhangwen", 0}, {"dacong", 0}};
int main(void)
{
int i;
char namel[10];
for(i = 0; i < 3; i++)
{
scanf("%29s",namel); /* 因为数组名就是地址 */
if(strcmp(namel, leader[i].name) == 0)
leader[i].count++;
}
printf("\n");
for(i = 0; i < 3; i++)
{
printf("%5s, %5d\n", leader[i].name, leader[i].count);
}
while(getchar() != '\n');
getchar();
return 0;
}
—>〉Sun〈<—