四则运算

Posted 花爷

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了四则运算相关的知识,希望对你有一定的参考价值。

#include<stdio.h>

#include<Windows.h>

#include<time.h>

void main()

{

      int a, b, c, d,i,m,n;

      float p, q;

      srand(unsigned( time(NULL)));

      for (i = 0; i < 30; i++)

     {

         a = rand() % 100;

         b = rand() % 100;

         c = rand() % 5;

         switch (c)

         {

         case 0: printf("%d + %d =\n", a, b);

         break;

         case 1:if (a < b)

         {

                    d = a;

                    a = b;

                    b = d;

         }

                printf("%d - %d =\n", a, b);

                break;

                case 2:printf("%d * %d =\n", a, b);

                break;

               case 3:

             while (b == 0)

            {

               b = rand() % 100;

             }

             printf("%d / %d =\n", a, b);

             break;

             case 4:

             a = rand() % 100;

             b = rand() % 100;

             m = rand() % 100;

             n = rand() % 100;

             c = rand() %4 ;

            while

以上是关于四则运算的主要内容,如果未能解决你的问题,请参考以下文章