fork download
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <cstdlib>
  5. #include <sstream>
  6. using namespace std;
  7.  
  8. int main() {
  9. int lineCount = 1;
  10. string line;
  11. while(getline(cin, line)){
  12.  
  13. int num1, num2;
  14. string num1Str, num2Str, num3Str, first, last;
  15. float num3;
  16.  
  17. stringstream ss(line);
  18.  
  19. getline(ss, num1Str, ',');
  20. getline(ss, num2Str, ',');
  21. getline(ss, first, ',');
  22. getline(ss, last, ',');
  23. getline(ss, num3Str);
  24.  
  25. num1 = stoi(num1Str);
  26. num2 = stoi(num2Str);
  27. num3 = stof(num3Str);
  28. cout <<lineCount<<endl<< num1 << "," << num2 << ","
  29. << first << "," << last <<"," << num3
  30. << "\n\t" << line << endl << endl;
  31. lineCount++;
  32. }
  33. }
Success #stdin #stdout 0s 4516KB
stdin
0,0,Person,One,16.1
1,1,Person,Two,5
1,1,Person,Three,12
0,1,Person,Four,.2
0,0,Person,Five,10.2
0,1,Person,Six,.3
1,0,Person,Seven,12.3
1,1,Person,Eight,4.2
1,0,Person,Nine,16.4
1,1,Person,Ten,1.4
stdout
1
0,0,Person,One,16.1
	0,0,Person,One,16.1

2
1,1,Person,Two,5
	1,1,Person,Two,5

3
1,1,Person,Three,12
	1,1,Person,Three,12

4
0,1,Person,Four,0.2
	0,1,Person,Four,.2

5
0,0,Person,Five,10.2
	0,0,Person,Five,10.2

6
0,1,Person,Six,0.3
	0,1,Person,Six,.3

7
1,0,Person,Seven,12.3
	1,0,Person,Seven,12.3

8
1,1,Person,Eight,4.2
	1,1,Person,Eight,4.2

9
1,0,Person,Nine,16.4
	1,0,Person,Nine,16.4

10
1,1,Person,Ten,1.4
	1,1,Person,Ten,1.4