Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include<string>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. ifstream file1;
  10. ifstream file2;
  11. file1.open("matrix1.csv");
  12. //file2.open("matrix2.csv");
  13.  
  14. int rows_matrix1 = 0,rows_matrix2 = 0;
  15. int cols_matrix1 = 0, cols_matrix2 =0;
  16. char value;
  17. int array[100][100];
  18. int i=0, j=0;
  19.  
  20. while(file1.good())
  21. {
  22.  
  23. value = file1.get();
  24. if(value == '\n')
  25. {
  26.  
  27. i++;
  28. rows_matrix1++;
  29. }
  30. else if(value == ',')continue;
  31. array[i][j] = (int)value;
  32. j++;
  33. cols_matrix1++;
  34.  
  35. }
  36.  
  37. for(int k=0;k<i;k++)
  38. {
  39. for(int y=0;y<j;y++)
  40. cout<<array[k][y];
  41. }
  42. file1.close();
  43. //file2.close();
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement