kestutis

2 lygis | 1 pamoka| Skaitymas

Nov 26th, 2013
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3.  
  4. const char duom[] = "Duomenys.txt";
  5. const char rez[] = "Rezultatai.txt";
  6.  
  7. int perskaitys_per_dienu(int n, const int a, const int b) {
  8.     int dienos = 0;
  9.     while( n > 0 )
  10.         n -= a + (b * dienos++);
  11.     return dienos;
  12. }
  13.  
  14. int main() {
  15.     int n, a, b;
  16.     ifstream in(duom);
  17.     ofstream out(rez);
  18.     while( in >> n >> a >> b )
  19.         out << perskaitys_per_dienu(n, a, b) << endl;    
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment