int main()
{
int a,b,c
do
{
system("cls")
printf(" 计算器菜单\n")
printf("========================\n")
printf("1:计算 a+b\n")
printf("2: 计算 a-b\n")
printf("3: 计算 a*b\n")
printf("4: 计算 a/b\n")
printf("5: 计算 a%b\n")
printf("0: 退出\n")
printf("请选择(0-5):")
scanf("%d",&c)
if(c!=0)
{
printf("请输入a:")
scanf("%d",&a)
printf("请输入b:")
scanf("%d",&b)
switch(c)
吵盯 {
case 1: printf("a+b=%d",a+b) break
case 2: 升埋和printf("液枝a-b=%d",a-b) break
case 3: printf("a*b=%d",a*b) break
case 4: printf("a/b=%d",a/b) break
case 5: printf("a%b=%d",a%b) break
default: break
}
printf("\n按任意键继续......")
getch()
}
}
while(c!=0)
return 0
}
#include<stdio.h>void main()
{ float f=555.5678,ff
int a[10]={ 0,1,2,3,4,5,6,7,8,9 },b[10],i
FILE *fp
if ( fp=fopen("TEXT.dat","wb+") )
{ fwrite(&f,sizeof(float),1,fp)
for ( i=0i<10i++ ) fwrite(&a[i],sizeof(int),1,fp)
fclose(fp)
} else printf("无法拿携建立文纯敏橡件。\n")goto ERROREND
if ( fp=fopen("TEXT.dat"做旁,"rb") )
{ fread(&ff,sizeof(float),1,fp)
for ( i=0i<10i++ ) fread(&b[i],sizeof(int),1,fp)
fclose(fp)
} else printf("无法打开文件。\n")goto ERROREND
printf("%.2f ",ff)for ( i=0i<10i++ ) printf("%d ",b[i])printf("\n")
ERROREND:
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)