float s(float *p,int n)
{ int i
float s=0.
for(i=0i<7i++,p++)
return s
}
void main()
float ave,sum
int i,n=0
sum=s(a,7)
printf("7天共接待参观人数为%.2f万人\n",sum)
ave=sum/7
printf("平均每天接待%.2f万人\n",ave)
for(i=0i<7i++)
printf("高于平均数的有%d天\n",n)
}
#include "stdio.h"#include "conio.h"
#include "graphics.h"
#include "math.h"
#define closegr closegraph
void initgr(void) /* BGI初始化 */
{
int gd = DETECT, gm = 0/* 和gd=VGA,gm=VGAHI是同样效果 */
registerbgidriver(EGAVGA_driver)/* 注册BGI驱动后可以不需要.BGI文件的支持运行 */
initgraph(&gd, &gm, "")
}
main()
{
int i, j
double a=5
double t
initgr()/* BGI初始化 */
/*y=x */
moveto(0,getmaxy()/2)
for (i=0i<4*314i++) {
t=(double)i/10
j=(int)(a*(1-cos(t/10))*10)
lineto(a*(t-sin(t/10)*10),getmaxy()/2-j)
}
getch()/* 暂停一下,看看前面绘图代码的运行结果 */
closegr()/* 恢复TEXT屏幕模式 */
}
key为按键,规定按下为低电平if(key==0)
{
delay(50); //延时50ms,消抖
if(key==0) //再判断是否按下
{
while(!key); 松手检测
··················································
该按键按下要实现的功能程序
··················································
}
}
我的习惯是这样写
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)