求大神可以帮忙编译一个C语言程序。输入一个8位数。输出前四位的和除以后四位的和。下面是我自己写的。
intnum[10];for(i=1;i<=8;i++){scanf("%d",&num[i]);}doublecalculate=(double)(num[1]+num...
int num[10];
for (i = 1; i <= 8; i++) {
scanf("%d", &num[i]);
}
double calculate = (double)(num[1] + num[2] + num[3] + num[4]) / (num[5] + num[6] + num[7] + num[8]);
printf("%g\n", calculate); 展开
for (i = 1; i <= 8; i++) {
scanf("%d", &num[i]);
}
double calculate = (double)(num[1] + num[2] + num[3] + num[4]) / (num[5] + num[6] + num[7] + num[8]);
printf("%g\n", calculate); 展开
1个回答
展开全部
#include<stdio.h>
#include<stdlib.h>
void c(void)
{
char ch;
while((ch=getchar())!='\n'&&ch!=EOF);
}
int main()
{
int num;
while(1)
{
while(1)
{
printf("input a number of 8 bit:");
scanf("%d",&num);
c();
if(num<10000000||num>99999999)
{
printf("input err!\n");
continue;
}
else
break;
}
printf("high 4 bit:%4d\nlow 4 bit:%4d\nresult:%f\n",num/10000,num%10000,((float)(num/10000))/(num%10000));
}
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询