Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- //Dekalruje zmienne
- int n;
- int a = 0;
- int b;
- int suma = 0;
- //Pobiera n
- cout << "Podaj liczbę calkowita: " << endl;
- cin >> n;
- while(n>a)
- {
- //Pobiera b, a następnie dodaje do sumy
- cout << "Podaj liczbe druga calkowita" << endl;
- cin >> b;
- suma += b;
- //Sprawdza czy b jest ujemne, jeśli tak dodaj do a
- if(b<0)
- {
- a++;
- }
- }
- //Wywala na ekran sume dodawania
- cout << "Suma wynosi:" << " " << suma << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement