Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     unsigned k;
  7.     cout << "Podaj k: " << endl;
  8.     cin >> k;
  9.  
  10.     for(int i = 0; i < k; i++) {
  11.         int liczba = 0;
  12.         unsigned liczbaElementow = 0;
  13.         int suma = 0;
  14.  
  15.         do{
  16.             cout << "Podaj liczbe: " << endl;
  17.             cin >> liczba;
  18.  
  19.             if(liczba != 0)
  20.                 liczbaElementow++;
  21.             suma += liczba;
  22.         } while (liczba != 0);
  23.  
  24.         cout << "Liczba elementow zestawu " << i+1 << ": " << liczbaElementow << endl;
  25.         cout << "Suma elemntow: " << suma << endl;
  26.     }
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement