bogdanNiculeasa

Pbinfo 2422 tripleta cu produs maxim cu backslash n

Nov 25th, 2023
1,020
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     ifstream fin("produsmaxim.in");
  9.     ofstream fout("produsmaxim.out");
  10.     int n;
  11.     while (fin >> n) {
  12.          int a, b, c; // a = b = c => 100% produsul maxim
  13.         a = b = c = n/3; // le am pus pe toate = n / 3, 7 /3, adica 2
  14.         b = (n - a) / 2;
  15.         c = n - b - a;
  16.         fout << n <<" " << a << " "<< b << " " << c << "\n"; // aparent \n e mai rapid decat << endl....
  17.  
  18.     }
  19.  
  20.  
  21.     fin.close();
  22.     fout.close();
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment