code (PDF)




File information


This PDF 1.4 document has been generated by VeryPDF Free Text To PDF Converter v1.5 / VeryPDF.com Inc (http://www.verypdf.com), and has been sent on pdf-archive.com on 10/06/2016 at 21:03, from IP address 182.68.x.x. The current document download page has been viewed 325 times.
File size: 2.07 KB (2 pages).
Privacy: public file










File preview


/*
ID: ******
PROG: gift1
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;
int main() {
ofstream fout ("gift1.out");
ifstream fin ("gift1.in");
int n,j,account[10],z,y;
for(int i=0;i<10;i++)
account[i]=0;
fin>>n;
char name[10][10];
for(int i=0;i<n;i++)
{
fin>>name[i];
}
int people[10],money[10];
char temp[10];
for(int i=0;i<n;i++)
{fin>>temp;
for(j=0;j<n;j++)
{
if(strcmp(name[j],temp)==0)
{
fin>>money[j]>>people[j];
break;
}
}
account[j]-=money[j];
if(people[j]==0)
{
z=0;
y=money[j];
}

else
{
y=money[j]%people[j];
z=(money[j]-y)/people[j]; }
account[j]+=y;
for(int k=0;k<people[j];k++)
{
fin>>temp;
for(int g=0;g<n;g++)
{
if(strcmp(name[g],temp)==0)
{
account[g]+=z;
break;
}
}
}
}
for(int i=0;i<n;i++)
{
fout<<name[i]<<" "<<account[i]<<endl;
}
return 0;
}






Download code



code.pdf (PDF, 2.07 KB)


Download PDF







Share this file on social networks



     





Link to this page



Permanent link

Use the permanent link to the download page to share your document on Facebook, Twitter, LinkedIn, or directly with a contact by e-Mail, Messenger, Whatsapp, Line..




Short link

Use the short link to share your document on Twitter or by text message (SMS)




HTML Code

Copy the following HTML code to share your document on a Website or Blog




QR Code to this page


QR Code link to PDF file code.pdf






This file has been shared publicly by a user of PDF Archive.
Document ID: 0000384029.
Report illicit content