zoukankan      html  css  js  c++  java
  • 软件工程个人作业02

     二柱子又遇到了老师新要求

    可怜的二柱子,可怜的我们啊

    #include<iostream>

    #include<time.h>

    using namespace std; ty

     
     

    pedef struct node{  

       int num1;     int num2;     char ope;     struct node *next; }node,*linknode;                                                        //定义三个操作数的数据结构,用于对产生数据的记录  

    void Math(int num,linknode &L,int chengchu,int fanwei,int yushu);       //产生数据 void InitList(linknode &L);                                             //链表初始化 void Insertlist(linknode &L,int one,int two,char thr);                  //插入数据 int Serchlist(linknode L,int one,int two,char thr);                     //查询节点 void Printrecord(linknode &L,int hang);                                 //输出数据 void menu1();                                                           //大要求的菜单选项 void choice(int *n);                                                    //对用户的提供的选择 void menu2();                                                           //是否有乘除法,数值范围,打印中每行的间隔可调整,除法有无余数, void standerd(int *n,int *f,int *y,int *h);

    void main() {     int num=5;        //出题数量     int chengchucan=0;     int fanweican=100;     int yushucan=0;     int hangcan=0;     linknode l;     InitList(l);     choice(&num);        standerd(&chengchucan,&fanweican,&yushucan,&hangcan);     Math(num,l,chengchucan,fanweican,yushucan);         //调用函数,产生数据     Printrecord(l,hangcan); }

    void menu1() {     cout<<"- - - - -  - - - - - - 菜单- - - - - - -- - - - - - "<<endl;     cout<<"                   1.定制出题数量                   "<<endl;     cout<<"                   2.定制打印                       "<<endl;                      //附加功能??     cout<<"                   3.退出菜单                       "<<endl;     cout<<"                   4.使用说明                       "<<endl;     cout<<"- - - - -  - - ---------------二柱子- "<<endl; }

    void menu2() {     cout<<"~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~菜单~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~"<<endl;     cout<<"                   1.是否有乘除法                  "<<endl;     cout<<"                   2.数值范围                       "<<endl;     cout<<"                   3.除法有无余数                   "<<endl;     cout<<"                   4.打印中每行的间隔可调整         "<<endl;     cout<<"                   5.退出菜单                       "<<endl;     cout<<"~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~~ ~ ~~ ~ ~ ~ ~ ~ ~ ~ 二柱子 ~"<<endl;

    }

    void choice(int *n) {     int choi,number;     menu1();     cout<<"请输入选择"<<endl;     cin>>choi;     while(choi!=3)     {         switch(choi)         {         case 1:             {                 cout<<"请输入题目数量"<<endl;                 cin>>number;                 *n=number;                 menu1();                 cin>>choi;                 break;             }         case 2:             {                 cout<<"定制打印"<<endl;                 menu1();                 cin>>choi;                 break;             }         case 4:             {                 cout<<" 使用说明书"<<endl;                 menu1();                 cin>>choi;                 break;             }                     }     } }

    void standerd(int *chengchu,int *fanwei,int *yushu,int *hangjian) {     int select,can1,can2,can3,can4;     menu2();     cout<<"请输入选择"<<endl;     cin>>select;     while(select!=5)     {         switch(select)         {         case 1:          //是否有乘除法             {                 cout<<"请输入选择 0代表设定乘除法1代表不设定乘除法(程序默认拥有乘除法)"<<endl;                 cin>>can1;                 if(can1==1)                     *chengchu=1;                 menu2();                 cin>>select;                 break;             }         case 2:        //数值范围             {                 cout<<"请输入 您想要的出题数值范围(程序默认数值范围为100以内)"<<endl;                 cin>>can2;                 *fanwei=can2;                 menu2();                 cin>>select;                 break;             }         case 3:       //除法有无余数             {                 cout<<"请输入选择 0代表设定允许余数1代表不允许除法有余数(程序默认会有余数)"<<endl;                 cin>>can3;                 *yushu=can3;                 menu2();                 cin>>select;                 break;             }         case 4:       //打印中每行的间隔可调整             {                 cout<<"请输入 您想要的打印题目之间的间隔(程序默认打印题目之间的间隔为0)"<<endl;                 cin>>can4;                 *hangjian=can4;                 menu2();                 cin>>select;                 break;             }         }     }

    } void Math(int num,linknode &L,int chengchu,int fanwei,int yushu) {     srand(time(NULL));     int a,b,c,rule;     char d;     int sancan=4;     int onecan=100;     if(chengchu==1)               //对乘除参数进行判断,为1时设置参数的改变         sancan=2;

        onecan=fanwei;                //对数值范围的修改,默认为     for(int x=0;x<num;x++)     {                a=rand()%onecan;          b=rand()%onecan;         c=rand()%sancan;         //cout<<"连续输入三个数"<<endl;       //测试产生数据相同时的结构是否成立         //cin>>a>>b>>c;         rule=0;         switch(c)         {         case 0:             d='+';             break;         case 1:             d='-';             break;         case 2:             d='*';             break;         case 3:             d='/';             break;         }         rule=Serchlist(L,a,b,d);         if(rule==0)         {             x--;             //cout<<"ji zhi "<<endl;         }         else if(yushu==1&&c==3&&a%b!=0)         {             x--;             cout<<"余数设置规则"<<endl;         }         else             Insertlist(L,a,b,d);             } }

    void InitList(linknode &L) {     L=new node;     L->next=NULL; }

    void Insertlist(linknode &L,int one,int two,char thr) {     linknode p=L;     while(p->next!=NULL)         p=p->next;     node * s=NULL;     s = (node *) malloc (sizeof(node));     s->num1=one;     s->num2=two;     s->ope=thr;     s->next=p->next;     p->next=s; }

    int Serchlist(linknode L,int one,int two,char thr) {     if(L->next==NULL)         return 1;     linknode p=L->next;     while(p!=NULL)     {         if(p->num1==one&&p->num2==two&&p->ope==thr)             return 0;         p=p->next;     }     return 1; }

    void Printrecord(linknode &L,int hang) {     int a=hang;     linknode p=L->next;     while(p    !=NULL)     {         cout<<p->num1<<p->ope<<p->num2<<"="<<endl;         while(hang>0)         {             cout<<endl;             hang--;         }         hang=a;         p=p->next;     } }

  • 相关阅读:
    vmware ubuntu 异常关机无法连接到网络
    Speed up GCC link
    常用的一些解压命令
    Log4j 漏洞复现
    Test Case Design method Boundary value analysis and Equivalence partitioning
    CCA (Citrix Certified Administrator) exam of “Implementing Citrix XenDesktop 4”
    What is Key Word driven Testing?
    SAP AGS面试小结
    腾讯2013终端实习生一面
    指针的引用
  • 原文地址:https://www.cnblogs.com/keaidejava/p/6560694.html
Copyright © 2011-2022 走看看