wheelsmanx

testing C++ split complex number string

Feb 19th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. string control = "2.4 + 3.5i";
  2. vector<string> controlGroupSplit = cStringSplit(control, ".");
  3. //vout(controlGroupSplit);
  4. vector<string> controlGroupSplitPlus = cStringSplit(controlGroupSplit[1], "+");
  5. //cout << endl;
  6. //vout(controlGroupSplitPlus);
  7. //cout << endl;
  8. vector<string> vectorToPass;
  9. vectorToPass.push_back(controlGroupSplit[0]);
  10. vectorToPass.push_back(controlGroupSplitPlus[0]);
  11. vectorToPass.push_back(controlGroupSplitPlus[1]);
  12. vectorToPass.push_back(controlGroupSplit[2].substr(0,controlGroupSplit.size()-2));
  13. //out(vectorToPass);
  14. vector<int> vectorOfIntsToPass;
  15. for (int i = 0; i < vectorToPass.size(); i++) {
  16. vectorOfIntsToPass.push_back(String2IntSingle(vectorToPass[i]));
  17. }
  18. //cout << endl;
  19. //vout(vectorOfIntsToPass);
  20. double temp = double(vectorOfIntsToPass[1]) / double(10);
  21. temp = temp + vectorOfIntsToPass[0];
  22. cout << temp << endl;
  23. double tempIm = double(vectorOfIntsToPass[3]) / double(10);
  24. tempIm = tempIm + vectorOfIntsToPass[2];
  25. cout << tempIm << endl;
Advertisement
Add Comment
Please, Sign In to add comment