fork download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. const int TEN = 10;
  6.  
  7. int strToNumber(char s[9]) {
  8. int num = 0;
  9. int i = 0;
  10. while (s[i] != '\0') {
  11. num = num * TEN + (s[i] - '0');
  12. ++i;
  13. }
  14. return num * num;
  15. }
  16.  
  17. int main() {
  18. char nr[9];
  19. cin.getline(nr, 9);
  20. cout << strToNumber(nr);
  21. }
Success #stdin #stdout 0.01s 5284KB
stdin
To school
stdout
1483122569