Advertisement
xTheEc0

Bandomasis I (Salama 2015m)

Jan 20th, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. #include <fstream>
  5. using namespace std;
  6. const char rezF[] = "U.txt";
  7.  
  8. int main()
  9. {
  10.     int rezultatas = 0;
  11.     int suma;
  12.     int x, c, v, b;
  13.     for (int i = 1000; i < 10000; i++)
  14.     {
  15.         x = i / 1000;
  16.         c = (i - (1000 * x)) / 100;
  17.         v = (i - (1000 * x) - (100 * c)) / 10;
  18.         b = i % 10;
  19.  
  20.         suma = x + c + v + b;
  21.         if (suma % 3 == 0)
  22.         {
  23.             rezultatas++;
  24.  
  25.         }
  26.     }
  27.  
  28.     ofstream rf(rezF);
  29.     rf << rezultatas << endl;
  30.     rf.close();
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement