Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
array project code c++ 2011
#1
Code:
#include <iostream> #include <fstream> #include <string> #include <iomanip> using namespace std; const int MAX_SCORES = 50; ifstream infile; void report(int numItems, string name[], int wins[], int losses[]); int readData(string name[], int wins[], int losses[]); void findAverage(int wins[], int losses[]); int main() { string name[MAX_SCORES]; int wins[MAX_SCORES]; int losses[MAX_SCORES]; int numItems; double average; numItems = readData(name, wins, losses); average = findAverage(wins, losses); report(numItems,name,wins,losses); findAverage(wins,losses); } int readData(string name[], int wins[], int losses[]) { infile.open("players.txt"); int count=0; while(infile.peek() !=EOF) { infile >> name[count] >> wins[count] >> losses[count]; count++; infile.ignore(1); } infile.close(); return count; } void report(int numItems, string name[], int wins[], int losses[]) { for (int i=0; i<numItems; i++) cout << name[i] << " " << wins[i] << " " << losses[i] << endl; } void findAverage(int numItems, int wins[], int losses[]) { double average; for(int i= 0; i <= numItems; i++) average= (wins[numItems]*100)/losses[numItems]; cout<< "The average value is: "<<average<<endl; } /*void bubbleSort (int numItems, string name[], int wins[], int losses[]) { string temp; int iteration; int index; for (iteration=1;iteration<numItems;iteration++) { for (index=0; index=numItems-iteration;index++) if (name[index]>name[index+1]); } temp=name[index]; name[index]=name[index+1]; name[index+1]=temp; cout << temp << endl; }*/

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  ASCII code is binary numbers of 0 and 1 in C++ 2012 Vuhelper 0 2,278 01-04-2012, 10:41 PM
Last Post: Vuhelper
  int x[10]; x[0]= 1; x[1]=2; if following code is executable in C++ 2012 Vuhelper 0 1,935 01-04-2012, 10:17 PM
Last Post: Vuhelper
  factorial in C++ code 2011 Vuhelper 0 943 12-10-2011, 06:31 PM
Last Post: Vuhelper
  stack during function call in C++ 2011 Vuhelper 0 2,025 11-05-2011, 05:05 PM
Last Post: Vuhelper
  What is the Thing Queue? in c++ 2011 Vuhelper 0 1,785 11-05-2011, 05:02 PM
Last Post: Vuhelper
  ASCII to char conversion code in C++ 2011 Vuhelper 0 1,720 11-05-2011, 05:01 PM
Last Post: Vuhelper
  How to write a summation in a sequence? C++ 2011-12 Vuhelper 2 1,355 09-19-2011, 04:53 AM
Last Post: Xpert
  GetPixel problem in c++ 2011-12 Vuhelper 0 2,504 09-18-2011, 07:12 PM
Last Post: Vuhelper
  C++ with loop code 2011-12 Vuhelper 0 975 09-18-2011, 07:09 PM
Last Post: Vuhelper
  how can i read the last letter of a input file? 2011 Vuhelper 0 1,832 09-12-2011, 10:24 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)