zoukankan      html  css  js  c++  java
  • 实验一

    #include<iostream.h>
    #include<stdlib.h>
    void DealInt(int m,int a[])
    {
    for(int p=0;p<m;p++)
    {
    int i=(int)rand()%10;
    int j=(int)rand()%10;
    int k=(int)rand()%100/25;
    switch(k)
    {
    case 0:
    cout<<i<<"+"<<j<<"=";
    a[p]=i+j;
    break;
    case 1:
    cout<<i<<"-"<<j<<"=";
    a[p]=i-j;
    break;
    case 2:
    cout<<i<<"*"<<j<<"=";
    a[p]=i*j;
    break;
    case 3:
    try
    {
    a[p]=i/j;
    cout<<i<<"/"<<j<<"=";
    }
    catch(...)
    {
    p--;
    }
    }
    if(p%5==4)
    {
    cout<<endl;
    }
    else
    {
    cout<<" ";
    }
    }
    }
    void DisplayInt(int a[],int w,int m)
    {
    if(w==1)
    {
    for(int q=0;q<m;q++)
    {
    cout<<a[q]<<" ";
    if(q%5==4)
    {
    cout<<endl;
    }
    }
    }
    else
    {};
    }
    void main()
    {
    int p;
    do
    {
    system("cls");
    int a[1000];
    int m,w;
    cout<<"请输入生成的四则运算题个数:";
    cin>>m;
    cout<<endl;
    DealInt(m,a);
    cout<<endl;
    cout<<"是否输出答案(输入1则输出答案否则不输出答案)"<<endl;
    cin>>w;
    if(w==1)
    {
    DisplayInt(a,w,m);
    }
    cout<<endl;
    cout<<"是否继续生成运算题(输入1则生成否则不生成)"<<endl;
    cin>>p;
    cout<<endl;
    }while(1==p);
    }

  • 相关阅读:
    js 多物体运动
    js运动 淡入淡出
    js运动 分享到
    正则 重复项最多得子项
    jq 拖拽
    jq 弹出窗口
    jq 选项卡
    jq 写法
    Codeforces 185A Plant( 递推关系 + 矩阵快速幂 )
    HDU 2604 Queuing( 递推关系 + 矩阵快速幂 )
  • 原文地址:https://www.cnblogs.com/chenqiuliang/p/4368142.html
Copyright © 2011-2022 走看看