Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int riceamount=2,
- squarenumber=1,
- totalamount=0,
- neededrice1000=0,
- neededrice1000000=0,
- neededrice1000000000=0;
- cout<<"Amount of rice you need for the square "<<
- squarenumber<<" is " <<riceamount-1<<endl;
- cout<<"Amount of rice you need for the square "<<
- squarenumber+1<<" is " <<riceamount<<endl;
- squarenumber=2;
- for(int i=2;i<65;i++)
- {
- riceamount=riceamount*2;
- ++squarenumber;
- cout<<"Amount of rice you need for the square "<< squarenumber<<" is " <<riceamount<<endl;
- totalamount=totalamount+ riceamount;
- if (totalamount>1000)
- squarenumber=neededrice1000;
- if (totalamount>10000000 && totalamount<1100000)
- squarenumber=neededrice1000000;
- if (totalamount>1000000000 && totalamount<1100000000)
- squarenumber=neededrice1000000000;
- }
- system("pause");
- return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement