Reading Arrays + Multiplication.

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
#include <iostream>
#include <fstream>
using namespace std;

ifstream datain ("Walnut_High_School");

int main(){
	int count = 0, player_number[30], weight[30];

	while(true)
	{
		if (datain.fail())
			break;
		datain >> player_number[count] >> weight[count];
		count++;
	}

	for(int i=0; i<20; i++)
	{
		cout << player_number[i] << "\t" << weight[i] <<endl;
	}

	cout << "\n" << "Amount of players: " <<--count<<endl; // correct order of numbers

	int smallest = 5000000, largest = 0; 

	for (int i=0; i<count ;i++)
	{
		if(player_number[i] < smallest)
			smallest = player_number[i];
		if(player_number[i] > largest)
			largest = player_number[i];
	}

	system("PAUSE");
	return 0;
}


I'm trying to remake my code to read 2 columns of a text file and multiply each number and make a third array.
Anyone want to help on this?
Topic archived. No new replies allowed.