zoukankan      html  css  js  c++  java
  • 课堂总结

    实验题目:随机产生30道100以内的四则运算

    思路:用rand产生两个随机数,然后用rand产生1.2.3.4代表加减乘除。之后输出。

    代码:

    #include<iostream>
    using namespace std;
    void main()
    {
    int a,b,c,n=30;


    for(n=0;n<30;n++)
    {
    a=rand()%100+1;
    b=rand()%100+1;
    c=rand()%4+1;

    if(c==1)
    cout<<a<<"+"<<b<<"="<<endl;
    if(c==2)
    cout<<a<<"-"<<b<<"="<<endl;
    if(c==3)
    cout<<a<<"*"<<b<<"="<<endl;
    if(c==4)
    cout<<a<<"/"<<b<<"="<<endl;
    }
    }

    问题:为什么课上没有做出?

    当时rand不知道如何用(a=rand()%100+1),没想到如何表示加减乘除。

  • 相关阅读:
    CodeForces 514B
    CodeForces 514A
    UVa 818
    HDU 1003
    UVa百题总结
    UVa 11526
    UVa 12412
    UVa 211
    UVa 1587
    UVa 225 – Golygons [DFS+剪枝]
  • 原文地址:https://www.cnblogs.com/double1/p/4319014.html
Copyright © 2011-2022 走看看