Facebook
From sada, 7 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 262
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.  int tb[10], last=0;
  10.  fstream we;
  11.  fstream wy;
  12.  
  13.  we.open("t.txt", ios::in);
  14.  if(we.good() != true)
  15.   {
  16.   cout << "blad";
  17.   return(1);
  18.   }
  19.  for(int i=0;i<10;i++)
  20.   {
  21.   if(we.eof() == true)
  22.   break;
  23.   we >> tb[i];
  24.   last=i;
  25.   }
  26. we.close();
  27. last += 1;
  28. cout << endl << "wczytano" << last <<" liczb:" << endl;
  29. for(int i=0; i<last; i++)
  30. cout << tb[i] <<" ";
  31. cout << endl;
  32.  
  33. wy.open("t2.txt", ios::out);
  34. if(wy.good() != true)
  35.  {
  36.  cout << "Blad";
  37.  return(2);
  38.  }
  39. for(int i=last-1; i>=0; i--)
  40. wy << tb[i] << " ";
  41. wy.close();
  42. return(0);
  43. }
  44.