fork download
  1. #include <iostream>
  2. //#include <fstream>
  3. #include <sstream>
  4. #include <string>
  5.  
  6. int main()
  7. {
  8. /*
  9.   std::ifstream file("zahlen.txt");
  10.   if (!file.is_open())
  11.   return -1;
  12.   */
  13. std::istream &file = std::cin; // <- for demo purposes only!
  14.  
  15. int array[3][8] = {};
  16. int num = 0;
  17.  
  18. for (int i = 0; i < 3; ++i)
  19. {
  20. std::string line;
  21. if (!std::getline(file, line))
  22. break;
  23.  
  24. std::istringstream iss(line);
  25. int u;
  26.  
  27. for (int j = 0; j < 8; ++j)
  28. {
  29. if (!(iss >> u))
  30. break;
  31.  
  32. array[num][j] = u;
  33. }
  34.  
  35. ++num;
  36. }
  37.  
  38. for (int i = 0; i < num; ++i)
  39. {
  40. for (int j = 0; j < 8; ++j)
  41. {
  42. std::cout << array[i][j];
  43. }
  44. std::cout << "\n";
  45. }
  46.  
  47. return 0;
  48. }
Success #stdin #stdout 0s 15240KB
stdin
0 0 0 0 1 1 0 1
0 0 0 1 0 0 1 1
1 1 0 1 0 1 1 0
stdout
00001101
00010011
11010110