calculating with 2Darrays

i wrote a code reading inputs from a text file which has 5 columns and 75 rows.i need to calculate the euclidean distance of each element in a column.

the code i have written to read the input is:
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
// 1sutundist.cpp : main project file.
#include "stdafx.h"
using namespace std;
void main(){
  float line;
  string str[32][75];
  int a=0,b=0,i,j,k;
  ifstream yourfile ("iristrain1sutun.txt");
  if (yourfile.is_open()){
	  while ( yourfile.good() )  {
	 getline (yourfile,str[a][b],' ');
     cout << str[a][b] <<  endl;
	  if(a==31){
		a=0;
		b++;
		getline(yourfile,str[a][b],' ');}
	  a++;}
	  yourfile.close();}
  else cout << "Unable to open file"; 
  float result[75];  
	  for(j=0;j<5;j++){
		  for(k=0;k<75;k++){
				result[k]=(str[0][0]-str[0][k])*(str[0][0]-str[0][k]);
		  }}
	  for(int i=0;i<75;i++){
		cout<< result[i]
	  }
  system("pause");
}


Last edited on
Topic archived. No new replies allowed.