gift1.cpp

来自「USACO chapter one.May hope it useful to 」· C++ 代码 · 共 48 行

CPP
48
字号
/*
ID: chenkai4
PROG: gift1
LANG: C++
*/
#include<iostream>
#include<fstream>
using namespace std;
ifstream in("gift1.in");
ofstream out("gift1.out");
string name[11];
int peoplenum,peopleout[11]={0},peoplein[11]={0};
int whichpeople(string thisname)
{
   for(int a=1;a<=peoplenum;a++)
      if(thisname==name[a])
         return a;
}
void cklovelyb()
{
    in>>peoplenum;
    for(int a=1;a<=peoplenum;a++)
       in>>name[a];
    string temp;
    while(in>>temp)
    {
        int nowout,money,outnum;string outname;
        nowout=whichpeople(temp);
        in>>money>>outnum;
        if(outnum>0)
        {
            peopleout[nowout]=(money/outnum)*outnum;
            for(int a=1;a<=outnum;a++)
            {
                in>>outname;
                peoplein[whichpeople(outname)]+=(money/outnum);
            }
        }
    }
    for(int a=1;a<=peoplenum;a++)
        out<<name[a]<<" "<<(peoplein[a]-peopleout[a])<<endl;
}
int main()
{
     cklovelyb();
	 return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?