Advertisement
MeehoweCK

Untitled

Dec 6th, 2020
642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     cin >> n;
  9.     int suma = 0;
  10.     int licznik = 0;
  11.     int liczba = 1;
  12.  
  13.     do
  14.     {
  15.         if(liczba % 10 == 2 || liczba % 10 == 3 || liczba % 10 == 9)
  16.         {
  17.             suma += liczba;
  18.             ++licznik;
  19.         }
  20.         ++liczba;
  21.     } while(licznik < n);
  22.    
  23.     // UWAGA: Pętla do (w przeciwieństwie do pętli while) wykonuje się ZAWSZE przynajmniej raz
  24.  
  25.     cout << suma << endl;
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement