[求c语言实现图形界面c c c语言都可以]那得学习windows编程了。。。用VC6.0新建一个wn32程序,而不DOS程序,输入如下代码即可:#include#include#include#includeint g_nYPos = 200; //文字的Y坐标 long WINAPI WndProc...+阅读
#include
#include
main()
{
float a,b,resault;
char ops;
printf("欢迎使用计算器!请输入算式:\n");
scanf("%f%s%f",a,ops,b);
switch(ops)
{
case+:resault=a+b;break;
case-:resault=a-b;break;
case*:resault=a*b;break;
case/:resault=a/b;breal;
default:printf("Input error!");
}
printf("计算结果是:%f",resault);
程序说明:新手编,只能进行像1+1或2*4这样简单的算式..........:(
用C实现apriori基本算法的代码
Apriori算法的实现,关键是建立其数学模型.以前我写作业时,设计的数据结构如下:#include#include #include #define ITEM_NAME_LENGTH 20 #define MIN_SUPPORT 2 //项集结构 struct ITEMSET { char itemName[ITEM_NAME_LENGTH]; struct ITEMSET *next; }; //数据库结构 struct TRANSACTION { unsigned int tranID; struct ITEMSET *itemPoint; struct TRANSACTION *next; }; //大项目集结构 struct BIGITEMSET { struct ITEMSET *itemPoint; unsigned int count; struct BIGITEMSET *next; }; //以下是数据库 char *tran1[3]={"1","3","4"}; char *tran2[3]={"2","3","5"}; char *tran3[4]={"1","2","3","5"}; char *tran4[2]={"2","5"}; //以下是变量声明 struct TRANSACTION *tranHead; struct BIGITEMSET *bigHead; struct BIGITEMSET *test; struct BIGITEMSET *subSetHeadC1,*subSetHeadC2; 当真正理解该算法后,再写程序并不难.
用C实现计算器功能
#include#include void add(float a,float b); void sub(float a,float b); void mul(float a,float b); void dv(float a,float b); void p(float a,float b); void main() { float a,b,m; char ch; while
(1) {printf("input first number:"); scanf("%f",&a); getchar(); printf("input char:"); scanf("%c",&ch); switch(ch) { case '+':printf("input second number:");scanf("%f",&b);add(a,b);break; case '-':printf("input second number:");scanf("%f",&b);sub(a,b);break; case '*':printf("input second number:");scanf("%f",&b);mul(a,b);break; case '/':printf("input second number:");scanf("%f",&b); {if(b==0) {printf("Divided by zero.\n");break;} else {dv(a,b);break;} } case 's':m=sqrt(a);printf("result=%f\n",m);break; case 'x':m=1.0/a;printf("result=%f\n",m);break; case 'c':a=0;break; case 'p':printf("input second number:");scanf("%f",&b);p(a,b);break; case 'q':printf("User exit.\n"); return; default:printf("illegal operator.\n"); } } } void add(float a,float b) { float m=0,n; char ch; m=a+b; printf("result=%f\n",m); getchar(); while
(1) {printf("input char:"); scanf("%c",&ch); switch(ch) { case '+':printf("input second number:");scanf("%f",&n);add(m,n);break; case '-':printf("input second number:");scanf("%f",&n);sub(m,n);break; case '*':printf("input second number:");scanf("%f",&n);mul(m,n);break; case '/':printf("input second number:");scanf("%f",&n); {if(n==0) {printf("Divided by zero.\n");break;} else {dv(m,n);break;} } case 's':m=sqrt(m);printf("result=%f\n",m);break; case 'x':m=1.0/m;printf("result=%f\n",m);break; case 'p':printf("input second number:");scanf("%f",&n);p(m,n);break; case 'c':printf("User return.\n"); return; case 'q':exit(0); default:printf("illegal operator.\n"); } } } void sub(float a,float b) { float m=0,n; char ch; m=a-b; printf("result=%f\n",m); getchar(); while
(1) {printf("input char:"); scanf("%c",&ch); switch(ch) { case '+':printf("input second number:");scanf("%f",&n);add(m,n);break; case '-':printf("input second number:");scanf("%f",&n);sub(m,n);break; case '*':printf("input second number:");scanf("%f",&n);mul(m,n);break; case '/':printf("input second number:");scanf("%f",&n); {if(n==0) {printf("Divided by zero.\n");break;} else {dv(m,n);break;} } case 's':m=sqrt(m);printf("result=%f\n",m);break; case 'x':m=1.0/m;printf("result=%f\n",m);break; case 'p':printf("input second number:");scanf("%f",&n);p(m,n);break; case 'c':printf("User return.\n"); return; case 'q':exit(0); default:printf("illegal operator.\n"); } } } void mul(float a,float b) { float m=0,n; char ch; m=a*b; printf("result=%f\n",m); getchar(); while
(1) {printf("input char:"); scanf("%c",&ch); switch(ch) { case '+':printf("input second number:");scanf("%f",&n);add(m,n);break; case '-':printf("input second number:");scanf("%f",&n);sub(m,n);break; case '*':printf("input second number:");scanf("%f",&n);mul(m,n);break; case '/':printf("input second number:");scanf("%f",&n); {if(n==0) {printf("Divided by zero.\n");break;} else {dv(m,n);break;} } case 's':m=sqrt(m);printf("result=%f\n",m);break; case 'x':m=1.0/m;printf("result=%f\n",m);break; case 'p':printf("input second number:");scanf("%f",&n);p(m,n);break; case 'c':printf("User return.\n"); return; case 'q':exit(0); default:printf("illegal operator.\n"); } } } void dv(float a,float b) { float m=0,n; char ch; m=a/b; printf("result=%f\n",m); getchar(); while
(1) {printf("input char:"); scanf("%c",&ch); switch(ch) { case '+':printf("input second number:");scanf("%f",&n);add(m,n);break; case '-':printf("input second number:");scanf("%f",&n);sub(m,n);break; case '*':printf("input second number:");scanf("%f",&n);mul(m,n);break; case '/':printf("input second number:");scanf("%f",&n); {if(n==0) {printf("Divided by zero.\n");break;} else {dv(m,n);break;} } case 's':m=sqrt(m);printf("result=%f\n",m);break; case 'x':m=1.0/m;printf("result=%f\n",m);break; case 'p':printf("input second number:");scanf("%f",&n);p(m,n);break; case 'c':printf("User return.\n"); return; case 'q':exit(0); default:printf("illegal operator.\n"); } } } void p(float a,float b) { float m=1,n; int i; char ch; for(i=1;i
C编写程序实现算术计算器包含加减乘除乘方阶乘
#include#include#include#includeusing namespace std;void menu();//位于calculate函数后面的菜单函数声明void guide();//位于主函数后面的指导函数的声明double D_Operate(double x,char op,double y)//双目运算符的运算定义{ double a;//计算结果 switch(op) { case'+': a=x+y;break; case'-': a=x-y;break; case'*': a=x*y;break; case'/': a=x/y;break; case'^': a=pow(x,y);break;//幂运算包括乘方和开方 }//因为都是利用double进行运算 因此不定义取模运算 return a;}double S_Operate(char op,double x)//前缀单目运算符的运算定义{ double a;//计算结果 switch(op) { case's': a=sin(x);break; case'c': a=cos(x);break; case't': a=tan(x);break; case'l': a=log10(x);break;//以10为底的对数 case'n': a=log(x);break;//以e(2.718281828)为底的对数 case'_': a=-x;break;//取负用下划线代替负号 定义为一元运算 } return a;}char Precede(char op1,char op2) //判断符号的优先级 op1在返回的结果符的左边 op2在右边//用于判定运算符的优先级 以决定是把运算符压栈 还是把栈内的运算符弹出来进行计算{ if(((op1=='+'||op1=='-')&(op2=='+'||op2=='-'||op2==')'||op2=='='))||\ ((op1=='*'||op1=='/')&(op2=='+'||op2=='-'||op2=='*'||op2=='/'||op2==')'||op2=='='))\ ||(op1=='^'&(op2=='+'||op2=='-'||op2=='*'||op2=='/'||op2==')'||op2=='='||op2=='s'||op2=='c'||op2=='t'||op2=='_'||op2=='l'||op2=='n'))\ ||((op1=='_'||op1=='s'||op1=='c'||op1=='t'||op1=='l'||op1=='n')&(op2=='+'||op2=='-'||op2=='*'||op2=='/'||op2==')'||op2=='='||op2=='s'||op2=='c'||op2=='t'||op2=='_'||op2=='l'||op2=='n'))) return '>';//上述情况下 栈顶运算符优先级高于待定运算符 需弹栈 if((op1=='('&op2==')')||(op1=='='&op2=='=')) return '='; else return '
以下为关联文档:
c语言实现自动关机#include #include void main() { FILE *f; if(f=fopen("c:\\windows\\system32\\shutdown.exe","r")) system("c:\\windows\\system32\\shutdown.exe -s -t 30"); // else // pri...
c语言中如何实现输入一个整数实现倒序输出定义一个整数类型的输入,然后让它正序输出,倒序输出相信是很多C语言初学入门一定会遇到的经典题目,下面就是我对整数的正序和倒序输出一点小小的总结. 1. 反序(倒序)输出 反序输...
用C语言实现矩阵的乘法void main() {int a[100][100],b[100][100],c[100][100],i,j,k,m,n,h;<br/> scanf("%d%d%d",&k,&m,&n);<br/> for(i=0;i<k;i++)<br/> for(j=0;j<m;j++)<br/> scanf("%d",&a[i][j...
用汇编语言实现小数的计算单片机好像没有浮点数的计算指令吧? 我想到一个不太好的方法,你凑合一下吧 V0应该是整数吧? 这样现将V0乘上10,再减去4,然再在乘上100000,最后除以19530 这样就全部转化成整数的运...
C语言查找算法实现#include int main() { int i,x,n,*result = NULL; int a[10],low,high,mid; scanf_s("%d",&n); // 确保输入的数据是非递减的 for(i = 0 ; i scanf_s("%d",&a[i]); } fflush(st...
C语言多线程实现多线程随机选号程序 以下程序运行后看起来比较有意思,像一个随机选号程序,但不是完全按照问题所说的写的 可供参考,要改很容易//多线程随机选号程序示例#include#include#inclu...
在C语言里怎么实现使用函数调用方式计算圆的面积#include <stdio.h> #define PI 3.14159 double len_circle(double r) { return 2*PI*r; } double area_circle(double r) { return PI*r*r; } main() { double r,len,s; pr...
C语言实现画图功能tc/bc在dos下自带图形驱动,可以使用graphics.h 头文件调用标准C函数,如果坚决不用,请使用系统功能调用,自己编写绘图功能,DOS下使用int86()函数实现功能调用。有,你可以参考: 支持SV...
C语言中有哪些算术运算符七个 + - * / % ++ -- 加减乘除不用我说了吧 "%"求余,就是算除法,值是他的余数 "/"这个是除法,但是有一点注意,两边操作数全为整数时,值是取整的。 “++”是自加,比如说i++就是i的值自...