Guest User

Untitled

a guest
Jul 17th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <stack>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     stack<int> first;
  9.     int toplam,i,limit;
  10.     toplam=0;
  11.  
  12.     cout<<"max sayi:";
  13.     cin>>limit;
  14.  
  15.     for(int i=0;i<=limit;i++)
  16.     {
  17.         first.push(i);
  18.     }
  19.     while(!first.empty())
  20.     {
  21.  
  22.         int z = (int) first.top();
  23.         toplam = toplam+z;
  24.         first.pop();
  25.     }
  26.  
  27.  
  28.     cout << "toplam :"<<toplam << endl;
  29.     return 0;
  30. }
Add Comment
Please, Sign In to add comment