Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- int parseLine(std::string s)
- {
- std::string delim = " ";
- size_t result;
- size_t i = 0;
- size_t cpu[7];
- auto start = 0U;
- auto end = s.find(delim);
- while (end != std::string::npos)
- {
- cpu[i] = std::atoi(s.substr(start, end - start).c_str());
- start = end + delim.length();
- end = s.find(delim, start);
- i++;
- }
- cpu[i] = std::atoi(s.substr(start, end - start).c_str());
- i = 0;
- size_t total = cpu[0] + cpu[1] + cpu[2] + cpu[3] + cpu[4] + cpu[5] + cpu[6];
- result = 100 * (1.0 - cpu[3] / total);
- return (result);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement