计算器

#include<stdio.h>
#include<stdlib.h>

int Add();
int Sub();
int Mul();
float Div();
int Fac();
int Rem();
int Sum();

int main(void)
{   

    int x,y;
    printf("进入登录页面\n");
    printf("账号: ");
    scanf("%d",&x);
    printf("密码: ");
    scanf("%d",&y);
    getchar(); 

    if(x==202504 && y==405202)
{
    printf("——————恭喜你成功登录账号——————\n");
    printf("-----------Loading----------\n");
    printf("\n");
    printf("!!!!欢迎使用R&Y计算器^_^!!!!");

        int L;
        while(L!=1)
        { 
        printf("\n");
        printf("-------------------分隔线------------------------\n");
        printf("———————————————————————————————————————————————\n");
        printf("|             Q----加法                        |\n");
        printf("|             W----减法                        |\n");
        printf("|             E----乘法                        |\n");
        printf("|             R----除法                        |\n");
        printf("|             T----求余                        |\n");
        printf("|             Y----阶乘                        |\n");
        printf("|             U----累加                        |\n");
        printf("|             I----结束                        |\n");
        printf("————————————————————————————————————————————————\n");
        
        printf("Select a function: ");
        int A;
        A=getchar();    
        switch (A)
        {
        case 'Q':
            Add();
            break;

        case 'W':
            Sub();
            break;

        case 'E':
            Mul();
            break;
            
        case 'R':
            Div();
            break;
           
        case 'T':
            Rem();
            break;
            
        case 'Y':
            Fac();
            break;

        case 'U':
            Sum();
            break;
    
        case 'I':
            L=1;
            printf("886");
            break;
        
        default:
            getchar();
            printf("!Not in the selection range!");
            break;
        }
        }
}

    else if(x!=202504 && y==405202)
    printf("账号不存在");
    else if(y!=405202 && x==202504)
    printf("密码出错");
    else
    printf("账号密码错误");
}
int Add()
{int q,o,p;
printf("please enter two numbers to Addition: ");
scanf("%d %d",&o,&p);
getchar();
q=o+p;
printf("%d+%d=%d\n",o,p,q);}

int Sub()
{int w,o,p;
printf("please enter two numbers to subtraction: ");
scanf("%d %d",&o,&p);
getchar();
w=o-p;
printf("%d-%d=%d\n",o,p,w);}

int Mul()
{int e,o,p;
printf("please enter two numbers to multiplication: ");
scanf("%d %d",&o,&p);
getchar();
e=o*p;
printf("%d*%d=%d\n",o,p,e);}

float Div()
{float r,o,p;
printf("please enter two numbers to division: ");
scanf("%f %f",&o,&p);
getchar();
r=o/p;
printf("%.2f/%.2f=%.2f\n",o,p,r);}

int Rem()
{int t,o,p;
printf("please enter two numbers to remainder: ");
scanf("%d %d",&o,&p);
getchar();
t=o%p;
printf("%d余%d=%d\n",o,p,t);}

int Fac()
{int y=1,o,p;
printf("please enter one number to factorial: ");
scanf("%d",&o);
getchar();
for(p=1;p<=o;p++)
y*=p;
printf("%d的阶乘是%d\n",o,y);}

int Sum()
{int u=0,o,p;
printf("please enter one number to accumulation: ");
scanf("%d",&o);
getchar();
for(p=0;p<=o;p++)
u+=p;
printf("%d的累加是%d\n",o,u);}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值