Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.05 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int parseLine(std::string s)
  5. {
  6. std::string delim = " ";
  7. size_t result;
  8. size_t i = 0;
  9. size_t cpu[7];
  10.  
  11. auto start = 0U;
  12. auto end = s.find(delim);
  13. while (end != std::string::npos)
  14. {
  15. cpu[i] = std::atoi(s.substr(start, end - start).c_str());
  16. start = end + delim.length();
  17. end = s.find(delim, start);
  18. i++;
  19. }
  20. cpu[i] = std::atoi(s.substr(start, end - start).c_str());
  21. i = 0;
  22. size_t total = cpu[0] + cpu[1] + cpu[2] + cpu[3] + cpu[4] + cpu[5] + cpu[6];
  23. result = 100 * (1.0 - cpu[3] / total);
  24. return (result);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement