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 RowVector2f coordinate(char str[])
     10 {
     11     RowVector2f v;
     12     v(0)=0;
     13     v(1)=0;
     14     char a[50],b[50];
     15     int i,j,k;
     16     j=0,k=0;
     17     for(i=1;str[i]!=',';i++)
     18     {
     19         v(0)=10*v(0)+str[i]-'0';
     20         j++;
     21     }
     22     i++;
     23     for(i;str[i]!=')';i++)
     24     {
     25         v(1)=10*v(1)+str[i]-'0';
     26         k++;
     27     }
     28     return v;
     29 }
     30 int main()
     31 {
     32     char name[50];
     33     int n;
     34     double ang,deg;
     35     char s1[50];
     36     char s2[50];
     37     char s3[50];
     38     char s4[50];
     39     char s5[50];
     40     char s6[50];
     41     RowVector2f v1;
     42     RowVector2f v2;
     43     RowVector2f v3;
     44     RowVector2f v4;
     45     Matrix2f rot;
     46     float pi=3.14159265;
     47     cout<<"请输入图形名称";
     48     cin>>name;
     49     cout<<"请输入图形端点数";
     50     cin>>n;
     51     cout<<"请输入图形端点坐标";
     52     if(n==1)
     53     {
     54         cin>>s1;
     55         v1=coordinate(s1);
     56     }
     57     else if(n==2)
     58     {
     59         cin>>s1;
     60         cin>>s2;
     61         v1=coordinate(s1);
     62         v2=coordinate(s2);
     63     }
     64     else if(n==3)
     65     {
     66         cin>>s1;
     67         cin>>s2;
     68         cin>>s3;
     69         v1=coordinate(s1);
     70         v2=coordinate(s2);
     71         v3=coordinate(s3);
     72     }
     73     else 
     74     {
     75         cout<<"输入有误";
     76     }
     77     cout<<"请输入一个计算指令";
     78     cin>>s4;
     79     if( strcmp(s4,"move")==0)
     80     {
     81         cout<<"请输入需变化图形名称";
     82         cin>>s5;
     83         cout<<"请输入变换坐标";
     84         cin>>s6;
     85         v4=coordinate(s6);
     86         if(n==1)
     87         {
     88             v1=v1+v4;
     89             cout<<"变换后的坐标为("<<v1<<"";
     90         }
     91         if(n==2)
     92         {
     93             v1=v1+v4;
     94             v2=v2+v4;
     95             cout<<"变换后的坐标为("<<v1<<")("<<v2<<"";
     96         }
     97         if(n==3)
     98         {
     99             v1=v1+v4;
    100             v2=v2+v4;
    101             v3=v3+v4;
    102             cout<<"变换后的坐标为("<<v1<<")("<<v2<<")("<<v3<<"";
    103         }
    104     }
    105     if( strcmp(s4,"rotate")==0)
    106     {
    107         cout<<"请输入需变化图形名称";
    108         cin>>s5;
    109         cout<<"请输入变换角度";
    110         cin>>ang;
    111         deg=ang/180*pi;
    112         rot(0,0)=cos(deg);
    113         rot(0,1)=sin(deg);
    114         rot(1,0)=-sin(deg);
    115         rot(1,1)=cos(deg);
    116         if(n==1)
    117         {
    118             v1=v1*rot;
    119             cout<<"变换后的坐标为("<<v1<<"";
    120         }
    121         if(n==2)
    122         {
    123             v1=v1*rot;
    124             v2=v2*rot;
    125             cout<<"变换后的坐标为("<<v1<<")("<<v2<<"";
    126         }
    127         if(n==3)
    128         {
    129             v1=v1*rot;
    130             v2=v2*rot;
    131             v3=v3*rot;
    132             cout<<"变换后的坐标为("<<v1<<")("<<v2<<")("<<v3<<"";
    133         }    
    134     } 
    135     return 0;
    136 }

  • 相关阅读:
    UVALive 5983 MAGRID DP
    2015暑假训练(UVALive 5983
    poj 1426 Find The Multiple (BFS)
    poj 3126 Prime Path (BFS)
    poj 2251 Dungeon Master 3维bfs(水水)
    poj 3278 catch that cow BFS(基础水)
    poj3083 Children of the Candy Corn BFS&&DFS
    BZOJ1878: [SDOI2009]HH的项链 (离线查询+树状数组)
    洛谷P3178 [HAOI2015]树上操作(dfs序+线段树)
    洛谷P3065 [USACO12DEC]第一!First!(Trie树+拓扑排序)
  • 原文地址:https://www.cnblogs.com/jayvee/p/5008516.html
Copyright © 2011-2022 走看看