zoukankan      html  css  js  c++  java
  • 第二次作业

      1 #include <iostream>
      2 #include <stdlib.h>
      3 #include <string.h> 
      4 #include <Eigen/Dense>
      5 #include <math.h>
      6 using namespace std;
      7 using namespace Eigen;
      8 using Eigen::MatrixXd;
      9 float pi=3.141592;
     10 RowVector2f move(char str[])
     11 {
     12     RowVector2f R;
     13     R(0)=0;
     14     R(1)=0;
     15     char a[60],b[60];
     16     int i,j,k;
     17     j=0,k=0;
     18     for(i=1;str[i]!=',';i++)
     19     {
     20         R(0)=10*R(0)+str[i]-'0';
     21         j++;
     22     }
     23     i++;
     24     for(i;str[i]!=')';i++)
     25     {
     26         R(1)=10*R(1)+str[i]-'0';
     27         k++;
     28     }
     29     return R;
     30 }
     31 int main()
     32 {
     33     int n;
     34     char name[60];
     35     double ang,deg;
     36     char T1[60];
     37     char T2[60];
     38     char T3[60];
     39     char T4[60];
     40     char T5[60];
     41     RowVector2f R1;
     42     RowVector2f R2;
     43     RowVector2f R3;
     44     RowVector2f R4;
     45     Matrix2f Rot;
     46     int C=1;
     47     while(C!=0)
     48 {
     49     cout<<"Please input name of graph:";
     50     cin>>name;
     51     cout<<"Please input number of points:";
     52     cin>>n;
     53     cout<<"Please input the endpoint:";
     54     if(n==1)
     55     {
     56         cin>>T1;
     57         R1=move(T1);
     58     }
     59     else if(n==2)
     60     {
     61         cin>>T1;
     62         cin>>T2;
     63         R1=move(T1);
     64         R2=move(T2);
     65     }
     66     else if(n==3)
     67     {
     68         cin>>T1;
     69         cin>>T2;
     70         cin>>T3;
     71         R1=move(T1);
     72         R2=move(T2);
     73         R3=move(T3);
     74     }
     75     else 
     76     {
     77         cout<<"!Input Error!";
     78     }
     79         cout<<"Please input a command:";
     80         cin>>T4;
     81         if( strcmp(T4,"Rotate")==0)
     82     {
     83         cout<<"Please input angle:";
     84         cin>>ang;
     85         deg=ang/180*pi;
     86         Rot(0,0)=cos(deg);
     87         Rot(0,1)=sin(deg);
     88         Rot(1,0)=-sin(deg);
     89         Rot(1,1)=cos(deg);
     90         if(n==1)
     91         {
     92             R1=R1*Rot;
     93             cout<<""<<R1<<""<<endl;
     94         }
     95         if(n==2)
     96         {
     97             R1=R1*Rot;
     98             R2=R2*Rot;
     99             cout<<""<<R1<<")("<<R2<<""<<endl;
    100         }
    101         if(n==3)
    102         {
    103             R1=R1*Rot;
    104             R2=R2*Rot;
    105             R3=R3*Rot;
    106             cout<<""<<R1<<")("<<R2<<")("<<R3<<""<<endl;
    107         }    
    108     } 
    109     if( strcmp(T4,"Move")==0)
    110     {
    111         cout<<"Please input the coordinate:";
    112         cin>>T5;
    113         R4=move(T5);
    114         if(n==1)
    115         {
    116             R1=R1+R4;
    117             cout<<""<<R1<<""<<endl;
    118         }
    119         if(n==2)
    120         {
    121             R1=R1+R4;
    122             R2=R2+R4;
    123             cout<<""<<R1<<")("<<R2<<""<<endl;
    124         }
    125         if(n==3)
    126         {
    127             R1=R1+R4;
    128             R2=R2+R4;
    129             R3=R3+R4;
    130             cout<<""<<R1<<")("<<R2<<")("<<R3<<""<<endl;
    131         }
    132     }
    133 }
    134     
    135     return 0;
    136 }





    
    
  • 相关阅读:
    迭代器Iterator与ConcurrentModificationException详解
    多线程 ForkJoinPool
    (转)面向对象——UML类图设计
    网络基础知识-网络协议
    Python 浅析线程(threading模块)和进程(process)
    一篇文章详解python的字符编码问题
    浅析文本挖掘(jieba模块的应用)
    浅析网站的基本构成和主要类型
    python 常用算法学习(1)
    浅谈使用git进行版本控制
  • 原文地址:https://www.cnblogs.com/huoshuilai/p/5014786.html
Copyright © 2011-2022 走看看