⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gift1.cpp

📁 USACO chapter one.May hope it useful to someone
💻 CPP
字号:
/*
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -