Metal Steak

Hard to eat

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  0 Posts :: 79 Stories :: 0 Comments :: 0 Trackbacks

公告

aaaaaaaaaaaa

常用链接

留言簿(1)

我参与的团队

搜索

  •  

最新评论

/*
    ID: chsc4691
    PROG: gift1
    LANG: C++
*/

#include 
<fstream>
using namespace std;

ifstream cin(
"gift1.in");
ofstream cout(
"gift1.out");

int n;

struct
fri
{
    
string name;
    
int
    money, given, recei;
    fri()
    {
        name 
= "";
        money 
= given = recei = 0;
    }
    
void
    give(
int outint i, fri *fa)
    {
        
if(money >= out)
        {
            
this -> money -= out;
            
this -> given += out;
            fa[i].money 
+= out;
            fa[i].recei 
+= out;
        }
    }
}friends[
11];

int
__locate__(
string name)
{
    
for(int i = 1; i <= n; i++)
        
if(friends[i].name == name)
            
return i;
    
return 0;
}

void
__read__()
{
    cin 
>> n;
    
for(int i = 1; i <= n; i++)
        cin 
>> friends[i].name;
    
for(int i = 1; i <= n; i++)
    {
        
string frin;
        
int
        mny, num, outn;
        cin 
>> frin >> mny >> num;

        
int j = __locate__(frin);
        friends[j].money 
= mny;

        
if(num != 0)
        {
            outn 
= mny / num;
            
for(int k = 1; k <= num; k++)
            {
                
string tn;
                cin 
>> tn;
                friends[j].give(outn, __locate__(tn), friends);
            }
        }
    }
}

void
__print__()
{
    
for(int i = 1; i <= n; i++)
        cout 
<< friends[i].name << " " << friends[i].recei - friends[i].given << endl;
}

int
main()
{
    __read__();
    __print__();

    
return 0;
}


posted on 2009-09-15 21:56 mad4alcohol 阅读(49) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航:   博客园   博客园最新博文   博问   管理