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 55 56 57 58
|
// PottsProj4.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
ofstream outfile;
ifstream infile;
void input(int a[], int b[], int c[]);
void output(int a[], int b[], int c[]);
int _tmain(int argc, _TCHAR* argv[])
{
int hits[20]={0}, walks[20]={0}, outs[20]={0};
input(hits, walks, outs);
output(hits, walks, outs);
return 0;
}
void input(int hits[], int outs[], int walks[])
{
int p1=0, h=0, w=0, o=0;
infile.open("d:\\baseball.txt");
infile >> p1 >> h >> w >> o;
while(!infile.eof())
{
int i=p1-1;
hits[i]=hits[i]+h;
outs[i]=outs[i]+w;
walks[i]=walks[i]+o;
}
infile.close();
return;
}
void output(int hits[], int outs[], int walks[])
{
int bat1=0;
outfile.open("d:\\BatStat.txt");
outfile << "Player " << "Average " << "Walks" << endl;
for(int i=0; i<20; i++)
{bat1=hits[i]/(hits[i]+outs[i]);
outfile << i+1 << " " << bat1 << " " << walks[i] << endl;
}
outfile.close();
return;
}
|