搜索
查看: 361|回复: 3
打印 上一主题 下一主题

一个高级计算器,大家一起找bug

[复制链接]
跳转到指定楼层
楼主
 楼主| 发表于 2018-7-23 19:09:29 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#include <stdio.h>
#include <stdlib.h>
#include<windows.h>
#include <math.h>

int main()
{
    system("color 0a");
    printf("这是一个高级计算器\n");
    Sleep(3000);
    printf("LODING...\n");
    int times,time,password,bye;
    bye=5;
    times=0;
    time=0;
    system("color 0a"); //以上全是开头
    {
            while(time<23)
            {
                    printf("\n");
                    time++;
                }
            while(times<80)
            {
                    printf(">");
                    Sleep(60);
                    times++;
            }
        }//模拟进度条
        printf("请输入密码");
        scanf("%d",&password);
        if(password==334310753)
        {
                printf("正确,继续");
                Sleep(1000);
                        goto l3;
                }
                else
                {
                        goto l1;
                }
        l3:float j1, j2, j3, bj, j, c, y1, y2, y3, c1, c2, c3, x2, z, z1, cfc, cfk, cfz, sd, sx, sz, ts, tx, tb1, tb2, tz, x21, yz, yc, k1, k2, Sin, Cos, tan, cot, a, b, d;
        float yj, yp, yzh, x;
        float x22, ztc, ztk, ztm;
        float tsd, txd, txg, txm;
        float sjd, sjg, sjm;
        float r, ym, x23;
        float x24, cftc, cftk, cftg, cftt;
        float yb, yg, yt;
        char aaa;
        int choose;
        //定义
        while(1>0)
        {
                system("cls");
                l4:printf("版本号:");
                printf("3.1\n");
                printf("开发者:QJM100");
                printf("341行代码不容易难免有错,若有bug请留言");
                system("color f1");
                {
                        printf("\n请选择你要计算的功能\n1:加法\n2:减法\n3:乘法\n4;除法\n5:周长计算\n6:面积计算\n7:体积计算\n8:平方根计算\n9:三角函数计算\n10:一元二次方程求解\n11:退出\n");
                        printf("|请输入序号|\n");
                        scanf("%f", &x);
                        system("cls");
                        if (x == 11)
                        {
                            printf("你确定? 1/2");
                            if(choose==1)
                            {
                                printf("bye");
                                goto l2;
                            }
                            if(choose==2)
                            {
                                    printf("返回中");
                                    while(time<23)
                                                    {
                                                            printf("\n");
                                                    time++;
                                                }
                                                    while(times<80)
                                                    {
                                                    printf(">");
                                                    Sleep(40);
                                                    times++;
                                                    }
                                                                goto l4;
                                                        }
                        }
                        if (x == 1)//加法
                        {
                                printf("好的,那么请输入第一个加数\n");
                                scanf("%f", &j1);
                                printf("第二个加数\n");
                                scanf("%f", &j2);
                                printf("计算中...\n");
                                Sleep(1000);
                                j3 = j1 + j2;
                                printf("答案是%f\n", j3);
                                system("pause");
                        }
                        if (x == 2)//减法
                        {
                                printf("好的,那么请输入被减数\n");
                                scanf("%f", &bj);
                                printf("第二个减数\n");
                                scanf("%f", &j);
                                printf("计算中...\n");
                                Sleep(1000);
                                c = bj - j;
                                printf("答案是%f\n", c);
                                system("pause");
                        }
                        if (x == 3)//乘法
                        {
                                printf("好的,那么请输入因数\n");
                                scanf("%f", &y1);
                                printf("因数\n");
                                scanf("%f", &y2);
                                printf("计算中...\n");
                                Sleep(1000);
                                y3 = y1*y2;
                                printf("答案是%f\n", y3);
                                system("pause");
                        }
                        if (x == 4)//除法
                        {
                                printf("好的,那么请输入被除数\n");
                                scanf("%f", &c1);
                                printf("除数\n");
                                scanf("%f", &c2);
                                printf("计算中...\n");
                                Sleep(1000);
                                c3 = c1 / c2;
                                printf("答案是%f\n", c3);
                                system("pause");
                        }
                        if (x == 5)//周长
                        {
                                printf("请选择需要的图形\n1正方形\n2长方形\n3三角形\n4梯形\n5圆形\n");
                                scanf("%f", &x2);
                                system("cls");

                        }
                        if (x2 == 1)//正方形
                        {
                                printf("请输入边长\n");
                                scanf("%f", &z);
                                z1 = 4 * z;
                                printf("正在计算...\n");
                                printf("结果是%f\n", z1);
                                system("pause");
                        }
                        if (x2 == 2)//长方形
                        {
                                printf("请输入长\n");
                                scanf("%f", &cfc);
                                printf("请输入宽\n");
                                scanf("%f", &cfk);
                                cfz = cfc + cfk + cfc + cfk;
                                printf("正在计算...\n");
                                printf("结果是%f\n", cfz);
                                system("pause");
                        }
                        if (x2 == 3)//三角形
                        {
                                printf("请输入底\n");
                                scanf("%f", &sd);
                                printf("斜边\n");
                                scanf("%f", &sx);
                                sz = sd + sx + sx;
                                printf("结果是%f\n", sz);
                                system("pause");
                        }
                        if (x2 == 4)//梯形
                        {
                                printf("请输入上底\n");
                                scanf("%f", &ts);
                                printf("请输入下底\n");
                                scanf("%f", &tx);
                                printf("斜边1\n");
                                scanf("%f", &tb1);
                                printf("斜边2\n");
                                scanf("%f", &tb2);
                                tz = ts + tx + tb1 + tb2;
                                printf("正在计算...\n");
                                printf("结果是%f\n", tz);
                                system("pause");
                        }
                        if (x2 == 5)//饕餮
                        {
                                printf("选项\n1精细\n2普通\n3粗略\n");
                                printf("精细圆周率为3.1415926\n普通为3.14\n初略为3\n");
                                scanf("%f", &x21);
                                system("cls");
                        }
                        if (x21 == 1)
                        {
                                printf("直径?\n");
                                scanf("%f", &yz);
                                yzh = yz*3.1415926;
                                printf("%f\n", yzh);
                                system("pause");
                        }
                        if (x21 == 2)
                        {
                                printf("直径?");
                                scanf("%f", &yz);
                                yzh = yz*3.14;
                                printf("%f", yzh);
                                system("pause");
                        }
                        if (x21 == 3)
                        {
                                printf("直径?");
                                scanf("%f", &yz);
                                yzh = yz * 3;
                                printf("%f", yzh);
                                system("pause");
                        }

                        if (x == 6)
                        {
                                printf("请查找选项\n");
                                printf("1正方形和长方形\n2梯形\n3三角\n4饕餮(圆)\n");
                                scanf("%f", &x22);
                                system("cls");
                        }
                        if (x22 == 1)
                        {
                                printf("长\n");
                                scanf("%f", &ztc);
                                printf("宽\n");
                                scanf("%f", &ztk);
                                ztm = ztc*ztk;
                                printf("%f\n", &ztm);
                                system("pause");
                        }
                        if (x22 == 2)
                        {
                                printf("上底  丄\n");
                                scanf("%f", &tsd);
                                printf("下底  丅\n");
                                scanf("%f", &txd);
                                printf("梯形高\n");
                                scanf("%f", &txg);
                                txm = (tsd + txd)*txg / 2;
                                printf("%f\n", txm);
                                system("pause");
                        }
                        if (x22 == 3)
                        {
                                printf("三角底\n");
                                scanf("%f", &sjd);
                                printf("三角高\n");
                                scanf("%f", &sjg);
                                sjm = sjd*sjg / 2;
                                printf("%f\n", sjm);
                                system("pause");
                        }
                        if (x22 == 4)
                        {
                                printf("选项\n");
                                printf("1精细\n2普通\n3一般\n");
                                scanf("%f", &x23);
                                system("cls");
                        }
                        if (x23 == 1)
                        {
                                printf("半径\n");
                                scanf("%f", &r);
                                ym = 3.1415926*(r*r);
                                printf("%f\n", ym);
                                system("pause");
                        }

                        if (x23 == 2)
                        {
                                printf("半径\n");
                                scanf("%f", &r);
                                ym = 3.14*(r*r);
                                printf("%f\n", ym);
                                system("pause");
                        }

                        if (x23 == 3)
                        {
                                printf("半径\n");
                                scanf("%f", &r);
                                ym = 3 * (r*r);
                                printf("%f\n", ym);
                                system("pause");
                        }
                        if (x == 7)
                        {
                                printf("请选择\n1长方体和正方体\n2圆柱(饕餮)\n3圆锥\n4球\n");
                                scanf("%f", &x24);
                                system("cls");
                                if (x24 == 1)
                                {
                                        printf("长?\n");
                                        scanf("%f", &cftc);
                                        printf("宽\n");
                                        scanf("%f", &cftk);
                                        printf("高\n");
                                        scanf("%f", &cftg);
                                        cftt = cftc*cftk*cftg;
                                        printf("%f", cftt);
                                        system("pause");
                                }
                                if (x24 == 2)
                                {
                                        printf("请输入半径\n");
                                        scanf("%f", &yb);
                                        printf("高\n");
                                        scanf("%f", &yg);
                                        yt = 3.14*(yb*yb)*yg;
                                        printf("%f", yt);
                                        system("pause");
                                }
                                if (x24 == 3)
                                {
                                        printf("请输入半径\n");
                                        scanf("%f", &yb);
                                        printf("高\n");
                                        scanf("%f", &yg);
                                        yt = 3.14*(yb*yb)*yg / 3;
                                        printf("%f", yt);
                                        system("pause");
                                }
                                if (x24 == 4)
                                {
                                        printf("请输入球体半径\n");
                                            scanf("%f", &yb);
                                        yt = 3.14*(yb*yb*yb) / 4 * 3;
                                        printf("%f", yt);
                                        system("pause");
                                }
                        }//-------------------------------
                        if (x == 8)
                        {
                                printf("请输入将要被开方的数:");
                                scanf("%lf", &k1);
                                k2 = sqrt(k1);
                                printf("/n答案约是:%f", k2);
                                system("pause");
                        }
                        if (x == 9)
                        {
                                double a, Sin, Cos, Tan, Cot;
                                printf("请输入你要求三角函数的变量a");
                                scanf("%f", &a);
                                Sin = sin(a);
                                Cos = sqrt(1 - Sin*Sin);
                                tan = Sin / Cos;
                                cot = 1 / Tan;
                                printf("\nsin a=%f\ncos a=%f\ntan a=%f\ncot a=%f", Sin, Cos, Tan, Cot);
                                system("pause");
                        }
                        if (x == 10)
                        {
                                printf("若ax2+bx+c=0,则x=[-b±√(b2-4ac)]/2a,请输入a,b,c");
                                scanf("%f", &a);
                                scanf("%f", &b);
                                scanf("%f", &c);
                                j1 = (-1 * b + sqrt(b*b - 4 * a*c)) / 2.0 / a;
                                j2 = (-1 * b + sqrt(b*b - 4 * a*c)) / 2.0 / a;
                                printf("\nx=%f或%f", j1, j2);
                                system("pause");
                        }
                    }
                }
    l1:printf("密码错误,退出\n");
       system("pause");
    l2:return 0;
}

沙发
发表于 2018-10-16 11:03:51 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
板凳
发表于 2018-10-16 11:11:23 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

广播台
特别关注
快速回复 返回顶部 返回列表