性感四则运算,在线答题

#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("\n请输入数字类型(1.整数 2.真分数) 0为退出程序: ");
scanf("%d",&n);
printf("\n请输入题目个数:");
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=\t",b);
scanf("%d",&re1);
if(re == re1)
{
    printf("T");
    printf("\n");
}
else
printf("F");
printf("\n");


}
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=\n",hua1);
}
else if(f%e==0)
{
hua1=f/e;
printf("1/%d=\n",hua1);
}
else
{
printf("%d/%d=\n",e,f);
}
scanf("%d/%d",&re3u,&re3d);
if(re2u == re3u&&re2d == re3d)
{
    printf("T");
    printf("\n");
}
else
printf("F");
printf("\n");
}
break;
}
break;
}
}
while(n!=-1);
}

 

 

posted on 2018-11-04 17:37  刘浩20160729  阅读(87)  评论(0编辑  收藏  举报

导航