搜索
查看: 5240|回复: 41
打印 上一主题 下一主题

一个超多功能的计算机

[复制链接]
楼主
发表于 2013-11-1 18:13:17 | 显示全部楼层
嗨,骚年,建议你看看我的,互相学习
终极计算器http://bbs.ahalei.com/thread-1099-1-1.html
沙发
发表于 2013-11-5 21:58:37 | 显示全部楼层
]#include <stdio.h>
#include <windows.h>
#include <string.h>
#include <conio.h>
#include <ctype.h>
#include <stdlib.h>
#include <malloc.h>
#include <dos.h>
main()
{
system("title 万能计算器");
system("color 1c");
printf(" \n──────────────────万能计算器────────────────  \n");
printf(" \t┏━━━━━━━━━━━━━━━━━━━━━┓\n");
printf(" \t┃1.科学计算器                              ┃\n");
printf(" \t┃2.八进制计算器                            ┃\n");
printf(" \t┃3.十六进制计算器                          ┃\n");
printf(" \t┃4.二进制计算器                            ┃\n");
printf(" \t┗━━━━━━━━━━━━━━━━━━━━━┛\n\n\n");
printf(" 请输入:");
char A;
A=getch();
{
if(A=='1')
{
system("title 科学计算器");
    while(1)
    {
    system("cls");
    system ("color 1c");
        int a,b,c,d,e,f;
      double i,m,n;
      const double pi=3.141592;
    printf("==========================================\n");
    printf("欢迎使用计算器。\n\n");
    printf("(a是关于三角函数与双曲三角函数,x)输入a:");
    scanf("%d",&a);
    printf("(b是关于反三角函数,对数,e为底指数,y)输入b:");
    scanf("%d",&b);
    printf("输入底数:\t");
    scanf("%d",&c);
    printf("输入指数:\t");
    scanf("%d",&d);
    printf("输入根:\t");
    scanf("%lf",&i);
    e=a+b;
    printf("和是%d\t",e);
    e=a*b;
    printf("积是%d\t",e);
    e=a-b;
    printf("差是%d\t",e);
    n=a/b;
    printf("商是%lf\n",n);
    e = pow(c, d);
    printf("乘方是%d\t\t\t",e);
    printf("二次根是%lf\n",sqrt(i));
    m=sin(a*pi/180);
    printf("sin正弦是%lf\t",m);
    m=sinh(a);
    printf("sinh双曲正弦是%lf\t",m);
    m=cos(a);
    printf("asin反正弦是%lf\t\n",m);
    m=acos(a);
    printf("cos余弦是%lf\t",m);
    m=cosh(a);
    printf("cosh双曲余弦是%lf\t",m);
    m=tan(a);
    printf("acos反余弦是%lf\t\n",m);
    m=atan(a);
    printf("tan正切是%lf\t",m);
    m=tanh(a);
    printf("tanh双曲正切是%lf\t",m);
    m=asin(a);
    printf("atan反正切(主值)是%lf\t",m);
    m = log10(b);
    printf("常用对数为:%lf\t",m);
    m = log(exp(b));
    printf("e为底指数为:%lf\t",m);
    m = hypot(a,b);
    printf("第三条边为:%lf\t",m);
    sleep(1000);
    printf("\n\n\n 请问您要再次使用吗? q.使用 其他键.关闭");
    printf("\n\n 请输入:");
  {
    char p;
    p=getch();
{
if(p=='q' || p=='q')
{

}
else
{
return 0;
}
}
}
}
}
{
if(A=='2')
{

system("title 八进制计算器");
    system ("color 1c");
    int a,b,c,d,e;
    while(1)
    {
    {
        system("cls");
    printf("==========================================\n");
    printf("欢迎使用八进制计算器。\n\n");
    printf("输入a:");
    scanf("%d",&a);
    printf("输入b:");
    scanf("%d",&b);
    printf("输入底数:\n");
    scanf("%d",&c);
    printf("输入指数:\n");
    scanf("%d",&d);
    e=a+b;
    printf("和是%o\n",e);
    e=a*b;
    printf("积是%o\n",e);
    e=a-b;
    printf("差是%o\t((0.xx)都为0)\n",e);
    e=a/b;
    printf("商是%o\n",e);
    e = pow(c, d);
    printf("乘方是%o\n",e);
    sleep(1000);
    printf("\n\n\n 请问您要再次使用吗? q.使用 其他键.关闭");
    printf("\n\n 请输入:");
{   
        char k;
    k=getch();
{
if(k=='q' || k=='q')
{

}
else
{
return 0;
}
}
}
}
}
}
{
if(A=='3')
{

system("title 十六进制计算器");
    system ("color 1c");
    int a,b,c,d,e;
    while(1)
    {
    {
        system("cls");
    printf("==========================================\n");
    printf("欢迎使用十六进制计算器。\n\n");
    printf("输入a:");
    scanf("%d",&a);
    printf("输入b:");
    scanf("%d",&b);
    printf("输入底数:\n");
    scanf("%d",&c);
    printf("输入指数:\n");
    scanf("%d",&d);
    e=a+b;
    printf("和是%x\n",e);
    e=a*b;
    printf("积是%x\n",e);
    e=a-b;
    printf("差是%x\n",e);
    e=a/b;
    printf("商是%x\t((0.xx)都为0)\n",e);
    e = pow(c, d);
    printf("乘方是%x\n",e);
    sleep(1000);
    printf("\n\n\n 请问您要再次使用吗? q.使用 其他键.关闭");
    printf("\n\n 请输入:");
{
        char D;
    D=getch();
{
if(D=='q' || D=='q')
{

}
else
{
return 0;
}
}
}
}
}
}
{
if(A=='4')
{
    system("cls");
int i;
char s[128];
printf("输入一个数:");
scanf("%d",&i);
itoa(i, s, 2);
printf("该数转换为二进制是: %s\n",s);
sleep(10000);
return 0;
}
}
}
}

}
}

点评

大神  发表于 2014-7-23 18:06
板凳
发表于 2013-11-8 20:41:37 | 显示全部楼层
4399APPLE 发表于 2013-11-6 11:19
很长,是不是啊?不过挺好用的

是挺好的.。。。。
地板
发表于 2013-11-8 20:42:45 | 显示全部楼层
4399APPLE 发表于 2013-11-6 11:19
很长,是不是啊?不过挺好用的

我还有个可以直接输入运算的计算器
5#
发表于 2013-11-8 20:45:25 | 显示全部楼层
本帖最后由 4k-Rn 于 2013-11-8 20:49 编辑
4399APPLE 发表于 2013-11-6 11:19
很长,是不是啊?不过挺好用的
  1. #include<stdio.h>
  2. #include<math.h>

  3. int main(void)
  4. {
  5.     /*init 0.0*/
  6.     double a = 0.0;
  7.     double b = 0.0;
  8.    
  9.     char op = '0';    /* + - * / ^*/
  10.    
  11.     printf("Enter a expression:");
  12.     /*must be %lf beacuse we use double*/
  13.     scanf("%lf%c%lf",&a,&op,&b);
  14.    
  15.     switch(op)
  16.     {
  17.         case '+':
  18.             printf("%.2f + %.2f = %.3f",a,b,(a+b));
  19.             break;
  20.         case '-':
  21.             printf("%.2f - %.2f = %.3f",a,b,(a-b));
  22.             break;
  23.         case '*':
  24.             printf("%.2f * %.2f = %.3f",a,b,(a*b));
  25.             break;
  26.         case '/':
  27.             if (fabs(b-0.0) < 0.0000001)
  28.             {
  29.                 printf("Input Err.\n");
  30.                 break;
  31.             }
  32.             printf("%.2f * %.2f = %.3f",a,b,(a/b));
  33.             break;
  34.         case '^':
  35.             printf("%.2f ^ %.2f = %.3f",a,b,pow(a,b));
  36.             break;
  37.         default:
  38.             printf("Input Err.\n");
  39.     }
  40.    
  41.     return 0;

  42. }
复制代码
6#
发表于 2013-11-8 20:46:57 | 显示全部楼层
4399APPLE 发表于 2013-11-6 11:19
很长,是不是啊?不过挺好用的

如果要复杂那种要运用栈的使用。
算法也不是很简单。。
要写稍微有点难度。。。
(1+2*4/2)-[123-(2342-34)]```````````这些问题。
我要是输入字母 呢 这些算法写在一起你要怎么办呢。
界面很难吗?只是分为好看和不好看。。
我以前的windows的计算器 写的很差 唯一特点能实现小数功能
现在想起来就丢人啊。。。
7#
发表于 2013-11-8 20:47:16 | 显示全部楼层
4399APPLE 发表于 2013-11-6 11:19
很长,是不是啊?不过挺好用的

还是VC++好
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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