Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LiczbaZespolona(string s){
- //w stringu szukamy albo + albo -
- //jak znajdziemy dzielimy wzdluz tego znaku i tworzymy liczbe zesp
- int sign = s.find_first_of("+-",1); //szukamy od 1 miejsca, bo tam
- //moze byc znak liczby ujemnej
- if(sign != string::npos){
- string tmpre = s.substr(0, sign);
- string re;
- for(int i=0; i< tmpre.length(); i++){
- if(tmpre[i] != ' ')
- re.append(tmpre.substr(i,i+1));
- }
- cout<<"Czesc rzeczywista: "<<re<<endl;
- this->re = atof(re.c_str());
- string tmpim = s.substr(sign, s.length()-sign);
- string im;
- for(int i=0; i< tmpim.length(); i++){
- if(tmpim[i] != ' ' && tmpim[i] != 'i')
- im.append(tmpim.substr(i,i+1));
- }
- cout<<"Czesc UROKURWAJONA: "<<im<<endl;
- this->im = atof(im.c_str());
- }else{
- cerr<<"kurwa blad"<<endl;
- }
- };
Add Comment
Please, Sign In to add comment