fork download
  1. #include <iostream>
  2. #include <cctype>
  3. #include <ctime>
  4. #include <string>
  5.  
  6. int main()
  7. {
  8. clock_t time;
  9.  
  10. std::string str("qWeRtY uIoP[ ]A SdfghJklk;'ZXcvbcxMMMBNBM,./dsadsdas");
  11. std::string dump(str);
  12.  
  13. time = clock();
  14.  
  15. for (long i = 0; i < 2000000; ++i)
  16. {
  17. str = dump;
  18. for (auto &c : str)
  19. {
  20. if (isalpha(c))
  21. c ^= 32;
  22. }
  23. }
  24.  
  25. std::cout << (double)time / CLOCKS_PER_SEC << std::endl;
  26.  
  27. time = clock();
  28.  
  29. for (long i = 0; i < 2000000; ++i)
  30. {
  31. str = dump;
  32. for (auto &c : str)
  33. {
  34. if (isalpha(c)) c ^= 32;
  35. }
  36. }
  37.  
  38. std::cout << (double)time / CLOCKS_PER_SEC << std::endl;
  39.  
  40. }
Success #stdin #stdout 3.02s 3028KB
stdin
Standard input is empty
stdout
0
1.52