1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
//main function
int main() {
int i, num_bids[0], max, sum = 0 ,num_auctions, x;
float bids[0];
//open input file
FILE * ifp = fopen("/Users/administrator/Desktop/bids.txt" , "r");
//open output file
FILE * ofp = fopen("/Users/administrator/Desktop/output.txt" , "w");
//scan in info
fscanf(ifp, "%d" , &num_auctions);
for(i=0; i<num_auctions; i++){
fscanf(ifp, "%d",&num_bids[i]);
for (x = 0; x < num_bids[i];x++)
{
fscanf(ifp, "%d", &bids[i]);
max = bids[i];
}
for(i=1; i<num_auctions; i++)
if (bids[0]>max)
max = bids[i];
}
//sum
sum += bids[i];
// print out to the output
fprintf(ofp,"Auction 1 was sold for $%.2f\n", bids[0]);
fprintf(ofp,"Auction 2 was sold for $%.2f\n", bids[1]);
fprintf(ofp,"Auction 3 was sold for $%.2f\n", bids[2]);
fprintf(ofp,"Auction 4 was sold for $%.2f\n", bids[3]);
fprintf(ofp,"Auction 5 was sold for $%.2f\n", bids[4]);
fprintf(ofp, "The total made for charity is $%.2f ", bids[i]);
// close
fclose(ifp);
fclose(ofp);
return 0;
}
|