Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #define INFINTY 10000
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int W = 1;
  10. int i = 0;
  11. int sum = 0;
  12. int summ = 0;
  13. int tab[INFINTY];
  14.  
  15.  
  16. do
  17. {
  18.  
  19. cout << "Podaj liczbę: " << endl;
  20. cin >> tab[i];
  21. if(tab[i]==0)
  22. {
  23. cout << endl;
  24. W = 0;
  25. }
  26. else
  27. {
  28. i++;
  29. }
  30. } while(W);
  31.  
  32. int arraySize = i;//sizeof(tab)/sizeof(tab[0]);
  33.  
  34. if(W==0)
  35. {
  36. for(int t=0; t<arraySize; t++)
  37. {
  38. cout << "Liczba = " << tab[t] << endl;
  39.  
  40. if(tab[t]>0)
  41. {
  42. sum += tab[t];
  43. }
  44. else if(tab[t]<0)
  45. {
  46. summ += tab[t];
  47. }
  48.  
  49. }
  50. cout << " + " << sum << endl;
  51. cout << " - " << summ << endl;
  52.  
  53. }
  54.  
  55.  
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement