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

    #include<stdio.h>
    #include<stdlib.h>
    #include<time.h>
    #define random(x) (rand()%x)
    void main()
    {
    int i,b,c,a=1,p,q,d=0;
    int dis=30;
    srand((int)time(0));
    printf("*1.加法*");
    printf("\n*2.减法*");
    printf("\n*3.乘法*");
    printf("\n*4.除法*\n");
    printf("*0.退出*\n");
    while(a)
    {
    printf("请选择:");
    scanf("%d",&c);
    getchar();
    switch(c)
    {
    case 0:exit(1);
    case 1:
    	for(i=0;i<10;i++)
    	{
    		p=random(dis);
    q=random(dis);
    	printf("%d+%d=",p,q);
    scanf("%d",&b);getchar();
    if(b==(p+q))
    {
    	printf("答对了~\n");
    	d=d+10;
    }
    else printf("答错了~\n");}
    	printf("本次练习得分为%d.\n",d);
    break;
    case 2:
    		for(i=0;i<10;i++)
    	{
    		p=random(dis);
    q=random(dis);
    printf("%d-%d=",p,q);
    scanf("%d",&b);getchar();
    if(b==(p-q)){
    printf("答对了~\n");
    d=d+10;}
    else printf("答错了~\n");}
    		printf("本次练习得分为%d.\n",d);
    break;
    case 3:
    		for(i=0;i<10;i++)
    	{
    		p=random(dis);
    q=random(dis);
    printf("%d*%d=",p,q);
    scanf("%d",&b);getchar();
    if(b==(p*q)){
    printf("答对了~\n");
    d=d+10;}
    else printf("答错了~\n");}
    		printf("本次练习得分为%d.\n",d);
    break;
    case 4:
    		for(i=0;i<10;i++)
    	{
    		p=random(dis);
    q=random(dis);
    printf("%d/%d=",p,q);
    scanf("%d",&b);getchar();
    if(b==(p/q)){
    printf("答对了~\n");
    d=d+10;}
    else printf("答错了~\n");}
    		printf("本次练习得分为%d.\n",d);
    break;
    }
    }
    }
    

      

  • 相关阅读:
    js数组中indesOf方法的使用
    js之数组排序
    大神的博客地址liferay
    CRM项目总结-封装PortletURLUtil
    有待整理
    摘要JSR168 PORLET标准手册汉化整理
    蓝色表格 -- 材料
    node 项目材料 集合
    一个浮动 css3效果
    代码 工具
  • 原文地址:https://www.cnblogs.com/wyh624945780/p/4370361.html
Copyright © 2011-2022 走看看