zoukankan      html  css  js  c++  java
  • 性感四则运算,在线答题

    #include<stdio.h>
    #include<stdlib.h>
    #include <time.h>
    main()
    {
    int a,b,c,d,e,f,k,i,n,t,N,re,re1,re2u,re2d,re3u,re3d,hua,hua1;
    srand(time(NULL));
    do{
    printf("
    请输入数字类型(1.整数 2.真分数) 0为退出程序: ");
    scanf("%d",&n);
    printf("
    请输入题目个数:");
    scanf("%d",&N);
    switch(n)
    {
    case 1:
    {
    for(i=0;i<N;i++)
    {
    a=rand()%100+1;
    b=rand()%100+1;
    k=rand()%4+1;
    printf("%d",a);
    switch(k)
    {
    case 1:printf("+");
     re=a+b;
     break;
    case 2:printf("-");
     re=a-b;
     break;
    case 3:printf("×");
     re=a*b;
     break;
    case 4:printf("÷");
     re=a/b;
     break;
    }
    printf("%d=	",b);
    scanf("%d",&re1);
    if(re == re1)
    {
        printf("T");
        printf("
    ");
    }
    else
    printf("F");
    printf("
    ");
    
    
    }
    break;
    }
    break;
    case 2:
    {
    for(i=0;i<N;i++)
    {
    c=rand()%100+1;
    d=rand()%100+1;
    e=rand()%100+1;
    f=rand()%100+1;
    k=rand()%4+1;
    if(c>d)
       {
        t=c;
        c=d;
        d=t;
       }
    if(e>f)
       {
        t=e;
        e=f;
        f=t;
       }
    if(c%d==0)
    {
        hua=c/d;
    printf("%d",hua);
    }
    else if(d%c==0)
    {
    hua=d/c;
    printf("1/%d",hua);
    }
    else
    {
    printf("%d/%d",c,d);
    }
    switch(k)
    {
    case 1:printf("+");
     re2u=c*f+d*e;
     re2d=d*f;
     if(re2u%re2d==0)
    {
        re2u=re2u/re2d;
        re=re2u;
    }
    else if(re2d%re2u==0)
    {
        re2d=re2d/re2u;
        re2u=1;
    }
    else
    {
    re2u=re2u;
    re2d=re2d;
    }
    
     break;
    case 2:printf("-");
      re2u=c*f-d*e;
     re2d=d*f;
      if(re2u%re2d==0)
    {
        re2u=re2u/re2d;
        re2d=1;
    }
    else if(re2d%re2u==0)
    {
        re2d=re2d/re2u;
        re2u=1;
    }
    else
    {
    re2u=re2u;
    re2d=re2d;
    }
     break;
    case 3:printf("×");
      re2u=c*e;
     re2d=d*f;
      if(re2u%re2d==0)
    {
        re2u=re2u/re2d;
        re2d=1;
    }
    else if(re2d%re2u==0)
    {
        re2d=re2d/re2u;
        re2u=1;
    }
    else
    {
    re2u=re2u;
    re2d=re2d;
    }
     break;
    case 4:printf("÷");
      re2u=c*f;
     re2d=d*e;
      if(re2u%re2d==0)
    {
        re2u=re2u/re2d;
        re2d=1;
    }
    else if(re2d%re2u==0)
    {
        re2d=re2d/re2u;
        re2u=1;
    }
    else
    {
    re2u=re2u;
    re2d=re2d;
    }
     break;
    }
    if(e%f==0)
    {
        hua1=e/f;
    printf("%d=
    ",hua1);
    }
    else if(f%e==0)
    {
    hua1=f/e;
    printf("1/%d=
    ",hua1);
    }
    else
    {
    printf("%d/%d=
    ",e,f);
    }
    scanf("%d/%d",&re3u,&re3d);
    if(re2u == re3u&&re2d == re3d)
    {
        printf("T");
        printf("
    ");
    }
    else
    printf("F");
    printf("
    ");
    }
    break;
    }
    break;
    }
    }
    while(n!=-1);
    }

  • 相关阅读:
    Git学习1:Git起步
    [转载]AMOLED结构详解,BOE专家给你分析驱动补偿
    [C#] Microsoft .Net框架SerialPort类的用法与示例
    API 的历史
    AMOLED原理介紹
    [C#] SHA1校验函数用法
    示波器基本原理之三:存储深度
    示波器基本原理之二:采样率
    示波器基本原理之一:带宽
    数字转中文
  • 原文地址:https://www.cnblogs.com/1742031541lh/p/9904629.html
Copyright © 2011-2022 走看看