把从键盘上输入的十进制数(long型)以二进制到十六进制形式输出。请填空。
int main(void)
{ char b[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',};
int c[64],d,i=0,base;
long n;
printf("enter a number :
");
scanf("%ld",&n);
printf("enter new base :
");
scanf("%d",&base);
do{ c[i]=____; i++; n= n╱base; }
while (n!=0 );
printf("transmite new base:
");
for (--i;i>=0;--i){ d=c[i];
printf("%c",____);}
return 0;}"
int main(void)
{ char b[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',};
int c[64],d,i=0,base;
long n;
printf("enter a number :
");
scanf("%ld",&n);
printf("enter new base :
");
scanf("%d",&base);
do{ c[i]=____; i++; n= n╱base; }
while (n!=0 );
printf("transmite new base:
");
for (--i;i>=0;--i){ d=c[i];
printf("%c",____);}
return 0;}"
举一反三
- 下面程序是将十进制数转换成不超过十六进制的n进制。请分析程序填空。 #include main() { int i=0,base,n,j,num[20]; printf("Enter data that will be converted:\n"); scanf("%d",&n); printf("Enter base:\n"); scanf("%d",&base); do { i++; num[i]=n【1】base; n=n【2】base; } while(n); printf("The data %d has been converted into the %d base data:\n",n,base); for(【3】) if(num[j]>9) putchar(num[j]+'A'-10); else putchar(num[j]+'0'); }
- 【填空题】#include <stdio.h> #define N 20 main(){ int a[N],i; for(i=0;i<N;i++)scanf("%d",【1】); for(i=0;i<N;i++) { if(【2】)【3】 printf("%3d",a[i]); } printf(" ") }
- 下面程序的功能是计算 S= 0!+1!+2!+…+k! ( k>=0 )。 #include "stdio.h" long fun(int n) { int i; long s=1; for(i=1; ① ;i++) s*=i; return( ② ); } int main() { int k,n; long s; scanf("%d",&n); s= ③ ; for(k=0;k<=n;k++) s+= ④ ; printf("%ld\n",s); return 0; }
- 以下程序的输出结果是n=4 #include void main() { int i,n=0; for(i=2;i<5;i++) { do { if(i%3) continue; n++; } while(!i); n++; } printf("n=%d",n); }
- 以下程序的功能是计算1到n的阶乘和,请填空。 long f(int n) { int i; long s; s=1; for(i=1; i <=n; i++) s=s*i; return s; } main() { long s; int k, n; scanf("%d", &n); s=0; for(k=0; k <=n; k++) s=s +_____ ;printf("%d\n",s); }