Guest User

Untitled

a guest
Jul 15th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. LiczbaZespolona(string s){
  2. //w stringu szukamy albo + albo -
  3. //jak znajdziemy dzielimy wzdluz tego znaku i tworzymy liczbe zesp
  4. int sign = s.find_first_of("+-",1); //szukamy od 1 miejsca, bo tam
  5. //moze byc znak liczby ujemnej
  6. if(sign != string::npos){
  7. string tmpre = s.substr(0, sign);
  8. string re;
  9. for(int i=0; i< tmpre.length(); i++){
  10. if(tmpre[i] != ' ')
  11. re.append(tmpre.substr(i,i+1));
  12. }
  13. cout<<"Czesc rzeczywista: "<<re<<endl;
  14. this->re = atof(re.c_str());
  15.  
  16. string tmpim = s.substr(sign, s.length()-sign);
  17. string im;
  18. for(int i=0; i< tmpim.length(); i++){
  19. if(tmpim[i] != ' ' && tmpim[i] != 'i')
  20. im.append(tmpim.substr(i,i+1));
  21. }
  22. cout<<"Czesc UROKURWAJONA: "<<im<<endl;
  23. this->im = atof(im.c_str());
  24. }else{
  25. cerr<<"kurwa blad"<<endl;
  26. }
  27. };
Add Comment
Please, Sign In to add comment