First time job

Source: Internet
Author: User

#include <iostream>
#include <stdlib.h>
#include <Eigen/Dense>
#include <math.h>
using namespace Std;
Using Eigen::matrixxd;
Matrixxd extract (char str[])
{
Matrixxd p (n);
int u;
int i,j;
Char a[10];
For (i=0;i<=49&&str[i]!= ' ('; i++);
For (j=0;j<=49&&str[j]!= ', '; j + +);
for (u=0;u<=10&&i!=j-1;u++)
{
i++;
A[u]=str[i];
}

P (0,0) =atof (a);
for (i=j;i<=49&&str[i]!= ') '; i++);
for (u=0;u<=10&&j!=i-1;u++)
{
j + +;
A[U]=STR[J];
}
P (0,1) =atof (a);
return p;
}
int main ()
{
Char name[15];
int n;
Double avg,deg;
float pi=3.1415926;
Char str1[20];
Char str2[20];
Char str3[20];
Char str4[15];
Char str5[15];
Char str6[15];
Matrixxd rot (2,2);
Matrixxd P1 ();
MATRIXXD P2 ();
Matrixxd P3 ();
MATRIXXD P4 ();
cout<< "Please enter";
cin>>name;
cin>>n;
Switch (n)
{
Case 1:
{
cin>>str1;
P1=extract (STR1);
}
Break
Case 2:
{
cin>>str1;
P1=extract (STR1);
cin>>str2;
P2=extract (STR2);
}
Break
Case 3:
{
cin>>str1;
P1=extract (STR1);
cin>>str2;
P2=extract (STR2);
cin>>str3;
P3=extract (STR3);
}
Break
default:cout<< "Input Error";

}
cout<< "Please enter operation instructions" <<endl;
cin>>str4;
if (str4[0]== ' m ' &&str4[1]== ' o ' &&str4[2]== ' V ' &&str4[3]== ' e ' &&str4[4]==0)
{
cin>>str5;
cin>>str6;
P4=extract (STR6);
if (n==1)
{
P1=P1+P4;
cout<< "(" <<p1<< ")" <<endl;
}
else if (n==2)
{
P1=P1+P4;
P2=P2+P4;
cout<< "(" <<p1<< ")" << "(" <<p2<< ")" <<endl;
}
Else
{
P1=P1+P4;
P2=P2+P4;
P3=P3+P4;
cout<< "(" <<p1<< ")" << "(" <<p2<< ")" << "(" <<p3<< ")" << Endl
}
}
else if (str4[0]== ' R ' &&str4[1]== ' o ' &&str4[2]== ' t ' &&str4[3]== ' a ' &&str4[4]== ' t ' &&str4[5]== ' E ' &&str4[6]==0)
{
cin>>str5;
cin>>avg;
Deg=avg/180*pi;
Rot (0,0) =cos (deg);
Rot (0,1) =sin (deg);
Rot (1,0) =-sin (deg);
Rot (=cos) (deg);
if (n==1)
{
P1=p1*rot;
cout<< "(" <<p1<< ")" <<endl;
}
else if (n==2)
{
P1=p1*rot;
P2=p2*rot;
cout<< "(" <<p1<< ")" << "(" <<p2<< ")" <<endl;
}
Else
{
P1=p1*rot;
P2=p2*rot;
P3=p3*rot;
cout<< "(" <<p1<< ")" << "(" <<p2<< ")" << "(" <<p3<< ")" << Endl
}

}
Else
{
cout<< "Input Error" <<endl;
}
return 0;
}

First time job

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.