fork download
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5. int rice_count = 0;
  6. std::cout << "Please, input maximum number of rice: ";
  7. std::cin >> rice_count;
  8. int square = 1;
  9. int square_count = 1;
  10. while(square <= rice_count)
  11. {
  12. std::cout << square_count << " square on the desk will have " << square << " rices" << std::endl;
  13. square_count++;
  14. if(square == 1)
  15. {
  16. square++;
  17. }
  18. else
  19. {
  20. square*=square;
  21. }
  22. }
  23. std::cout << square_count << " square on the desk will have " << square << " rices" << std::endl;
  24.  
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
Please, input maximum number of rice: 1 square on the desk will have 1 rices