提交记录 #515
提交时间:2024-12-23 18:26:42
语言:c
状态:Unaccepted
编译情况:编译成功
固定测试点#1:
附加测试点暂不可用
65【应用】恭喜发财 利是窦来
#include<stdio.h>
#include<string.h>
struct people{
char name[15];
int cash;
};
void calcu_1(struct people * people,int change,int n)
{
people->cash=people->cash-change*n;
return ;
}
void calcu_2(struct people * people,int n)
{
people->cash=people->cash+n;
return ;
}
int main()
{
int N;
scanf("%d",&N);
struct people people[N];
for(int i=0;i<N;++i)
{
scanf("%s",people[i].name);
people[i].cash=0;
}
for(int i=0;i<N;++i)
{
char tem[15];
scanf("%s",tem);
int num;
scanf("%d %d",&people[i].cash,&num);
int change;
if(num!=0) change=people[i].cash/num;
else change=0;
calcu_1(&people[i],change,num);
if(num!=0){
scanf("%s",tem);
while(i==N-1||strcmp(tem, people[i+1].name) != 0)
{
for(int j=0;j<N;++j)
{
if(strcmp(tem, people[j].name)==0)
{
calcu_2(&people[j],change);
break;
}
}
scanf("%s",tem);
}
}
}
for(int i=0;i<N;++i)
{
printf("%s %d\n",people[i].name,people[i].cash);
}
return 0;
}