Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<ctype.h>
- #include<cmath>
- #include<iomanip>
- using namespace std;
- int main()
- {
- string n;
- getline(cin,n);
- double a,b,c,d;
- a=0;
- b=0;
- c=0;
- d=0;
- double x,y,z;
- for(int i=0; i<n.size(); i++)
- {
- if(n[i]=='n' && isdigit(n[i+1])==1 && isdigit(n[i+2])==1 )
- {
- a=a+(n[i+1]-'0')*10+(n[i+2]-'0');
- }
- else if(n[i]=='n' && isdigit(n[i+1])==1 )
- {
- a=a+(n[i+1]-'0');
- }
- if(n[i]=='s' && isdigit(n[i+1])==1 && isdigit(n[i+2])==1 )
- {
- b=b+(n[i+1]-'0')*10+(n[i+2]-'0');
- }
- else if(n[i]=='s' && isdigit(n[i+1])==1 )
- {
- b=b+(n[i+1]-'0');
- }
- if(n[i]=='w' && isdigit(n[i+1])==1 && isdigit(n[i+2])==1 )
- {
- c=c+(n[i+1]-'0')*10+(n[i+2]-'0');
- }
- else if(n[i]=='w' && isdigit(n[i+1])==1 )
- {
- c=c+(n[i+1]-'0');
- }
- if(n[i]=='e' && isdigit(n[i+1])==1 && isdigit(n[i+2])==1 )
- {
- d=d+(n[i+1]-'0')*10+(n[i+2]-'0');
- }
- else if(n[i]=='e' && isdigit(n[i+1])==1 )
- {
- d=d+(n[i+1]-'0');
- }
- }
- x=a-b;
- y=c-d;
- z=sqrt(pow(a-b,2)+pow(c-d,2));
- cout<<fixed<<setprecision(2)<<z;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement