下面程序是将十进制数转换成不超过十六进制的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'); }
举一反三
- 把从键盘上输入的十进制数(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;}"
- 下面程序是将十进制数转换成不超过十六进制的n进制。请分析程序填空。 #inclu...tchar(num[j]+'0'); }
- 以下程序的输出结果是#include<;stdio.h>;int fun6(int num){ int k=1;do{ k*=num%10; num/=10;}while(num);return k;}main( ){ int n=26;printf(“%d\n”,fun6(n));}
- main(){int num=0;while(num<;=2){num++;printf("%d\n",num);}}
- 【填空题】#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(" ") }