C语言 压岁钱
发布网友
发布时间:2022-05-29 22:48
我来回答
共5个回答
热心网友
时间:2024-09-16 20:39
好水的练习题呵,c++还是拿STL做的... 人家要C的,就不要弄STL了
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Unit
{
char chname[15];
long lrecvmoney;
long lsendmoney;
int nsend;
char sendname[10][15];
}person[10];
int N;
void work();
void work()
{
FILE *pf;
pf = fopen("in.in","r");
fscanf(pf,"%d",&N);
int i,j,k;
for(i=0;i<N;i++)
{
fscanf(pf,"%s",person[i].chname);
person[i].lrecvmoney = 0L;
person[i].lsendmoney = 0L;
person[i].nsend = 0;
}
char tname[15],tname2[15];
long l1;
int n2;
fscanf(pf,"%s",tname);
fscanf(pf,"%ld",&l1);
fscanf(pf,"%d",&n2);
while(l1!=0L||n2!=0L)
{
for(i=0;i<N;i++)
if(strcmp(person[i].chname,tname)==0)
{
person[i].lsendmoney = l1;
person[i].nsend = n2;
if(n2==0)
person[i].lrecvmoney +=person[i].lsendmoney;
else
person[i].lrecvmoney +=person[i].lsendmoney - person[i].lsendmoney/person[i].nsend*person[i].nsend;
for(j=0;j<n2;j++)
{
fscanf(pf,"%s",tname2);
for(k=0;k<N;k++)
if(strcmp(person[k].chname,tname2)==0)
{
person[k].lrecvmoney += person[i].lsendmoney/person[i].nsend;
break;
}
}
break;
}
fscanf(pf,"%s",tname);
fscanf(pf,"%ld",&l1);
fscanf(pf,"%d",&n2);
}
fclose(pf);
pf = fopen("out.out","w");
for(i=0;i<N;i++)
{
fprintf(pf,"%s %ld\n",person[i].chname,person[i].lrecvmoney - person[i].lsendmoney);
}
fclose(pf);
}
int main(int argc, char *argv[])
{
work();
system("PAUSE");
return 0;
}
热心网友
时间:2024-09-16 20:39
#include <stdio.h>
#include <map.h>
#include <string.h>
using namespace std;
string name[10];
int money[10];
int main()
{
int n;
map<string,int> M;
scanf("%d",n);
fill(money,money+n,0);
for(int i=0;i<n;i++){
scanf("%s"name[i]);
M[name[i]]=i;
}
string s1,s2;
while(scanf("%s",s1)){
int t1,t2;
scanf("%d,%d",t1,t2);
if(t2)money[M[s1]]-=t1/t2*t2;
for(int i=0;i<t2;i++){
scanf("%s",s2)
money[M[s2]]+=t1/t2;
}
}
for(int i=0;i<n;i++){
printf("%s, %d",name[i]money[i]);
printf("\n");
}
}
热心网友
时间:2024-09-16 20:40
压岁钱就是给小孩的零钱
热心网友
时间:2024-09-16 20:40
#include <iostream>
#include <map>
#include <string>
using namespace std;
string name[10];
int money[10];
int main()
{
int n;
map<string,int> M;
cin>>n;
fill(money,money+n,0);
for(int i=0;i<n;i++){
cin>>name[i];
M[name[i]]=i;
}
string s1,s2;
while(cin>>s1){
int t1,t2;
cin>>t1>>t2;
if(t2)money[M[s1]]-=t1/t2*t2;
for(int i=0;i<t2;i++){
cin>>s2;
money[M[s2]]+=t1/t2;
}
}
for(int i=0;i<n;i++){
cout<<name[i]<<" "<<money[i]<<endl;
}
}
热心网友
时间:2024-09-16 20:41
kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
热心网友
时间:2024-09-16 20:39
好水的练习题呵,c++还是拿STL做的... 人家要C的,就不要弄STL了
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Unit
{
char chname[15];
long lrecvmoney;
long lsendmoney;
int nsend;
char sendname[10][15];
}person[10];
int N;
void work();
void work()
{
FILE *pf;
pf = fopen("in.in","r");
fscanf(pf,"%d",&N);
int i,j,k;
for(i=0;i<N;i++)
{
fscanf(pf,"%s",person[i].chname);
person[i].lrecvmoney = 0L;
person[i].lsendmoney = 0L;
person[i].nsend = 0;
}
char tname[15],tname2[15];
long l1;
int n2;
fscanf(pf,"%s",tname);
fscanf(pf,"%ld",&l1);
fscanf(pf,"%d",&n2);
while(l1!=0L||n2!=0L)
{
for(i=0;i<N;i++)
if(strcmp(person[i].chname,tname)==0)
{
person[i].lsendmoney = l1;
person[i].nsend = n2;
if(n2==0)
person[i].lrecvmoney +=person[i].lsendmoney;
else
person[i].lrecvmoney +=person[i].lsendmoney - person[i].lsendmoney/person[i].nsend*person[i].nsend;
for(j=0;j<n2;j++)
{
fscanf(pf,"%s",tname2);
for(k=0;k<N;k++)
if(strcmp(person[k].chname,tname2)==0)
{
person[k].lrecvmoney += person[i].lsendmoney/person[i].nsend;
break;
}
}
break;
}
fscanf(pf,"%s",tname);
fscanf(pf,"%ld",&l1);
fscanf(pf,"%d",&n2);
}
fclose(pf);
pf = fopen("out.out","w");
for(i=0;i<N;i++)
{
fprintf(pf,"%s %ld\n",person[i].chname,person[i].lrecvmoney - person[i].lsendmoney);
}
fclose(pf);
}
int main(int argc, char *argv[])
{
work();
system("PAUSE");
return 0;
}
热心网友
时间:2024-09-16 20:40
#include <stdio.h>
#include <map.h>
#include <string.h>
using namespace std;
string name[10];
int money[10];
int main()
{
int n;
map<string,int> M;
scanf("%d",n);
fill(money,money+n,0);
for(int i=0;i<n;i++){
scanf("%s"name[i]);
M[name[i]]=i;
}
string s1,s2;
while(scanf("%s",s1)){
int t1,t2;
scanf("%d,%d",t1,t2);
if(t2)money[M[s1]]-=t1/t2*t2;
for(int i=0;i<t2;i++){
scanf("%s",s2)
money[M[s2]]+=t1/t2;
}
}
for(int i=0;i<n;i++){
printf("%s, %d",name[i]money[i]);
printf("\n");
}
}
热心网友
时间:2024-09-16 20:40
压岁钱就是给小孩的零钱
热心网友
时间:2024-09-16 20:41
#include <iostream>
#include <map>
#include <string>
using namespace std;
string name[10];
int money[10];
int main()
{
int n;
map<string,int> M;
cin>>n;
fill(money,money+n,0);
for(int i=0;i<n;i++){
cin>>name[i];
M[name[i]]=i;
}
string s1,s2;
while(cin>>s1){
int t1,t2;
cin>>t1>>t2;
if(t2)money[M[s1]]-=t1/t2*t2;
for(int i=0;i<t2;i++){
cin>>s2;
money[M[s2]]+=t1/t2;
}
}
for(int i=0;i<n;i++){
cout<<name[i]<<" "<<money[i]<<endl;
}
}
热心网友
时间:2024-09-16 20:41
kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
热心网友
时间:2024-09-16 20:39
好水的练习题呵,c++还是拿STL做的... 人家要C的,就不要弄STL了
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Unit
{
char chname[15];
long lrecvmoney;
long lsendmoney;
int nsend;
char sendname[10][15];
}person[10];
int N;
void work();
void work()
{
FILE *pf;
pf = fopen("in.in","r");
fscanf(pf,"%d",&N);
int i,j,k;
for(i=0;i<N;i++)
{
fscanf(pf,"%s",person[i].chname);
person[i].lrecvmoney = 0L;
person[i].lsendmoney = 0L;
person[i].nsend = 0;
}
char tname[15],tname2[15];
long l1;
int n2;
fscanf(pf,"%s",tname);
fscanf(pf,"%ld",&l1);
fscanf(pf,"%d",&n2);
while(l1!=0L||n2!=0L)
{
for(i=0;i<N;i++)
if(strcmp(person[i].chname,tname)==0)
{
person[i].lsendmoney = l1;
person[i].nsend = n2;
if(n2==0)
person[i].lrecvmoney +=person[i].lsendmoney;
else
person[i].lrecvmoney +=person[i].lsendmoney - person[i].lsendmoney/person[i].nsend*person[i].nsend;
for(j=0;j<n2;j++)
{
fscanf(pf,"%s",tname2);
for(k=0;k<N;k++)
if(strcmp(person[k].chname,tname2)==0)
{
person[k].lrecvmoney += person[i].lsendmoney/person[i].nsend;
break;
}
}
break;
}
fscanf(pf,"%s",tname);
fscanf(pf,"%ld",&l1);
fscanf(pf,"%d",&n2);
}
fclose(pf);
pf = fopen("out.out","w");
for(i=0;i<N;i++)
{
fprintf(pf,"%s %ld\n",person[i].chname,person[i].lrecvmoney - person[i].lsendmoney);
}
fclose(pf);
}
int main(int argc, char *argv[])
{
work();
system("PAUSE");
return 0;
}
热心网友
时间:2024-09-16 20:40
#include <stdio.h>
#include <map.h>
#include <string.h>
using namespace std;
string name[10];
int money[10];
int main()
{
int n;
map<string,int> M;
scanf("%d",n);
fill(money,money+n,0);
for(int i=0;i<n;i++){
scanf("%s"name[i]);
M[name[i]]=i;
}
string s1,s2;
while(scanf("%s",s1)){
int t1,t2;
scanf("%d,%d",t1,t2);
if(t2)money[M[s1]]-=t1/t2*t2;
for(int i=0;i<t2;i++){
scanf("%s",s2)
money[M[s2]]+=t1/t2;
}
}
for(int i=0;i<n;i++){
printf("%s, %d",name[i]money[i]);
printf("\n");
}
}
热心网友
时间:2024-09-16 20:40
压岁钱就是给小孩的零钱
热心网友
时间:2024-09-16 20:41
#include <iostream>
#include <map>
#include <string>
using namespace std;
string name[10];
int money[10];
int main()
{
int n;
map<string,int> M;
cin>>n;
fill(money,money+n,0);
for(int i=0;i<n;i++){
cin>>name[i];
M[name[i]]=i;
}
string s1,s2;
while(cin>>s1){
int t1,t2;
cin>>t1>>t2;
if(t2)money[M[s1]]-=t1/t2*t2;
for(int i=0;i<t2;i++){
cin>>s2;
money[M[s2]]+=t1/t2;
}
}
for(int i=0;i<n;i++){
cout<<name[i]<<" "<<money[i]<<endl;
}
}
热心网友
时间:2024-09-16 20:41
kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
热心网友
时间:2024-09-16 20:40
好水的练习题呵,c++还是拿STL做的... 人家要C的,就不要弄STL了
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Unit
{
char chname[15];
long lrecvmoney;
long lsendmoney;
int nsend;
char sendname[10][15];
}person[10];
int N;
void work();
void work()
{
FILE *pf;
pf = fopen("in.in","r");
fscanf(pf,"%d",&N);
int i,j,k;
for(i=0;i<N;i++)
{
fscanf(pf,"%s",person[i].chname);
person[i].lrecvmoney = 0L;
person[i].lsendmoney = 0L;
person[i].nsend = 0;
}
char tname[15],tname2[15];
long l1;
int n2;
fscanf(pf,"%s",tname);
fscanf(pf,"%ld",&l1);
fscanf(pf,"%d",&n2);
while(l1!=0L||n2!=0L)
{
for(i=0;i<N;i++)
if(strcmp(person[i].chname,tname)==0)
{
person[i].lsendmoney = l1;
person[i].nsend = n2;
if(n2==0)
person[i].lrecvmoney +=person[i].lsendmoney;
else
person[i].lrecvmoney +=person[i].lsendmoney - person[i].lsendmoney/person[i].nsend*person[i].nsend;
for(j=0;j<n2;j++)
{
fscanf(pf,"%s",tname2);
for(k=0;k<N;k++)
if(strcmp(person[k].chname,tname2)==0)
{
person[k].lrecvmoney += person[i].lsendmoney/person[i].nsend;
break;
}
}
break;
}
fscanf(pf,"%s",tname);
fscanf(pf,"%ld",&l1);
fscanf(pf,"%d",&n2);
}
fclose(pf);
pf = fopen("out.out","w");
for(i=0;i<N;i++)
{
fprintf(pf,"%s %ld\n",person[i].chname,person[i].lrecvmoney - person[i].lsendmoney);
}
fclose(pf);
}
int main(int argc, char *argv[])
{
work();
system("PAUSE");
return 0;
}
热心网友
时间:2024-09-16 20:40
#include <stdio.h>
#include <map.h>
#include <string.h>
using namespace std;
string name[10];
int money[10];
int main()
{
int n;
map<string,int> M;
scanf("%d",n);
fill(money,money+n,0);
for(int i=0;i<n;i++){
scanf("%s"name[i]);
M[name[i]]=i;
}
string s1,s2;
while(scanf("%s",s1)){
int t1,t2;
scanf("%d,%d",t1,t2);
if(t2)money[M[s1]]-=t1/t2*t2;
for(int i=0;i<t2;i++){
scanf("%s",s2)
money[M[s2]]+=t1/t2;
}
}
for(int i=0;i<n;i++){
printf("%s, %d",name[i]money[i]);
printf("\n");
}
}
热心网友
时间:2024-09-16 20:41
压岁钱就是给小孩的零钱
热心网友
时间:2024-09-16 20:41
#include <iostream>
#include <map>
#include <string>
using namespace std;
string name[10];
int money[10];
int main()
{
int n;
map<string,int> M;
cin>>n;
fill(money,money+n,0);
for(int i=0;i<n;i++){
cin>>name[i];
M[name[i]]=i;
}
string s1,s2;
while(cin>>s1){
int t1,t2;
cin>>t1>>t2;
if(t2)money[M[s1]]-=t1/t2*t2;
for(int i=0;i<t2;i++){
cin>>s2;
money[M[s2]]+=t1/t2;
}
}
for(int i=0;i<n;i++){
cout<<name[i]<<" "<<money[i]<<endl;
}
}
热心网友
时间:2024-09-16 20:42
kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk