數據選擇小程序
阿新 • • 發佈:2018-08-20
work art char pri cost scan string string.h can
#include <stdio.h>
#include <string.h>
void main()
{
struct staff
{
char name[20];
char department[20];
int salary;
int cost;
}worker[3]=
{
{"Xu_Guo","part1",800,200},
{"Wu_Xia","part2",1000,300},
{"Li_Jun","part3",1200,350}
};
int i;
char xname[20];
printf("\nInput the worker\‘s name:");
scanf("%s",xname);
for(i=0;i<3;i++)
if(strcmp(xname,worker[i].name)==0)
{
printf("* * * * %s * * * *",xname);
printf("\n salary:%6d",worker[i].salary);
printf("\n cost:%6d",worker[i].cost);
printf("\n payed:%6d",worker[i].salary-worker[i].cost);
}
}
數據選擇小程序