Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #define INFINTY 10000
- using namespace std;
- int main()
- {
- int W = 1;
- int i = 0;
- int sum = 0;
- int summ = 0;
- int tab[INFINTY];
- do
- {
- cout << "Podaj liczbę: " << endl;
- cin >> tab[i];
- if(tab[i]==0)
- {
- cout << endl;
- W = 0;
- }
- else
- {
- i++;
- }
- } while(W);
- int arraySize = i;//sizeof(tab)/sizeof(tab[0]);
- if(W==0)
- {
- for(int t=0; t<arraySize; t++)
- {
- cout << "Liczba = " << tab[t] << endl;
- if(tab[t]>0)
- {
- sum += tab[t];
- }
- else if(tab[t]<0)
- {
- summ += tab[t];
- }
- }
- cout << " + " << sum << endl;
- cout << " - " << summ << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement