zoukankan      html  css  js  c++  java
  • 四则运算

    设计思想:

            从c++方法出发,按照所给出的要求,先用代码将运算符输入程序中,用printf、scanf语句保证可以定制出题数目,用for循环实现出题数目并保证不重复,用rand语句保证一到一百以内的数的四则运算。

    源程序代码:

    #include <stdio.h>

    #include <stdlib.h>

    #include <time.h>

    int main(){

                      int n, m, i, j, num;

                      srand(time(0));

                      char sc[] = {'+', '-', '*', '/'};

                      printf("输入生成的算式个数:");

                      scanf("%d", &n);

                      for(i=0; i<n; i++){

                                       m = 1;

                                       for(j=0; j<m; j++){

                                                      num = rand() % 100 + 1;

                                                      printf("%d %c ", num, sc[rand()%4]);

                                       }

                                       printf("%d", rand() % 100 + 1);

                                       printf(" = ");

                     }

                     return 0;

  • 相关阅读:
    工程师的十层楼,上
    工程师的十层楼 (下)
    2011CCTV中国经济年度人物评选结果揭晓
    IT行业程序员薪水差距之大的原因是什么
    单片机C应用开发班
    【分享】对输入子系统分析总结
    P6156 简单题 题解
    P3911 最小公倍数之和 题解
    dp 做题记录
    UVA12298 Super Poker II 题解
  • 原文地址:https://www.cnblogs.com/zhs20160715/p/9749587.html
Copyright © 2011-2022 走看看