已知字符0的ASCII码为十六进制的30,下面程序的输出是___________。 int main() { union { unsigned char c; unsigned int i[4]; } z; z.i[0]=0x39; z.i[1]=0x36; printf("%cn",z.c); return 0; }
已知字符0的ASCII码为十六进制的30,下面程序的输出是___________。 int main() { union { unsigned char c; unsigned int i[4]; } z; z.i[0]=0x39; z.i[1]=0x36; printf("%cn",z.c); return 0; }
参考答案和解析
0110110B
相关考题:
下面是一个简单的使用RAWSOCKET实现的ping程序,填入(n)处。/*simple ping program*/struct sockaddr_in saddr;int rawsock;unsigned short in_cksum(unsigned short*addr, int len){ int sum=0;unsigned short res=0;while(1en>1){sum+=*addr++; len-=2;}if(len=1){*((unsigned char *)(res))=*((unsigned char *)addr); sum+=res;}sum=(sum>>16)+(sam 0xffff);sum+=(sum>>16); res=~sum;return res;}void ping(int signo){int len;int i;static unsigned short seq=0;char buff[8192];struct timeval tv;struet icmp*icmph=(struct icmp * )buff;long*data=(long*)icmph→icmp_data;bzero(buff, 8192);gettimeofday(tv, NULL);icmph→icmp_type=ICMP_ECHO;icmph→icmp_code=0;icmph→icmp_cksum=0;icmph→icmp_id=0;icmph→icmp_seq=0;icmph→icmp_id=getpid()0xffff;icmph→icmp_seq=seq++;data[0]=tv.tv_sec;data[1]=tv.tv_usec;for(i=8; i< ; i++)icmph→icmp_data[i]=(unsigned char)i;icmph→icmp_cksum=in_cksum((unsigned short *)buff, ? 72);len; sendto(rawsock, buff, 72, 0, saddr, sizeof(saddr));alarm(1);}void sigint(int signo){ printf("CATCH SIGINT !!! \n");close(rawsock);exit(0);}void dumppkt(char*buf, int len){ struct ip*iph=(struct ip*)buf;int i=iph→ip_h1*4;struct icmp*icmph=(struct icmp*)buf[i];long*data=(long*)iemph→icmp_data;struct timeval tv;gettimeofday(tv, NULL);if(icmph→icmp_type! =ICMP_ECHOREPLY)return;if(icmph→icmp_id! =(getpid()0xffff))return;printf("From %s:ttl=% d seq=% d time=%.2f ms\n",inet_ntoa(iph→ip_src),iph→ip_ttl?,icmph→icmp_seq,(tv.tv_see-data[0])*1000.0+(tv.tv_usec-data[0])/1000.0);}int main(int argc, char*argv[]){ int len;stuct timeval now;char recvbuff[8192];if(1){printf("%s aaa.bbb.ccc.ddd\n", argv[0]);exit(1);}rawsock=soeket(AF_INET, (2), IPPROTO_ICMP);if(rawsock<0) {perror("soeket");exit(1);}bzero ( saddr, sizeof(saddr));saddr.sin_family=(3);if( inet_aton( argv[1], saddr.sin_addr) <0) {printf("invalid IP address: %s\n", argv[1]);exit(1);}signal(SICALRM, ping);signal(SICINT, sigint);alarm(1);while (1){len=read (4), recvbuff, 8192);if( len<0 errno=EINTR)continue;else it( len<0)perror("read");else if( len>0)dumppkt(recvbuff, len);}close (5);exit(0);}
请补充函数proc,该函数的功能是:把从主函数中输入的由数字字符组成的字符串转换成一个无符号长整数,并且逆序输出。结果由函数返回。例如,输入:1234567,结果输出:7654321。 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅在函数proc的横线上填人所编写的若干表达式或语句。 试题程序: includestdlib.h includeconio.h include stdio.h includestring.h unsigned long proc(char*str) { unsigned long t=0: int k: int i=0; i=str|en(str); for(【1】 ;i=0;i--) { k= 【2】 ; t= 【3】 ; } return t; } void main { char str[8]; system("CLS"); printf("Enter a string made up of0to 9 digital character:\n"); gets(str); printf("The string,is:%s\n",str); if(strlen(str)8) printf("The string is too tong!"); else printf("The result:%1u\n", proc(str)); }
以下程序的输出结果是 ( ) main( ) { union { char i [2]; int k; } r; r. i[0]=2,r.i[1]=0; printf("%d\n",r,k); }A.2B.1C.0D.不确定
有下列程序,其中%u表示按无符号整数输出。 main() {unsigned int x=0xFFFF;/*x的初值为十六进制数*/ printf("%u\n",x); } 程序运行后的输出结果是( )。A.-1B.65535C.32767D.0xFFFF
下面程序的输出结果是______。 unsigned fun(unsigned num) { unsigned k=1; do{ k*=num%10; num/=10; }while(num); return(k); } main() { unsigned n=26; printf("%d\n",fun(n)); }A.0B.4C.12D.无限次循环
有以下程序:includeunion pw{int i; char ch[2];}a;main(){a.ch[0]=13;a.ch[1]=0;prin 有以下程序: #include<stdio.h> union pw { int i; char ch[2]; }a; main() { a.ch[0]=13;a.ch[1]=0;printf("%d\n",a.i);} 程序的输出结果是( )。A.13B.14C.208D.209
以下程序的输出结果是( )。 main {int x=0.5;char z=a; printf("%d\n",(x2));}A.0S 以下程序的输出结果是( )。 main {int x=0.5;char z=a; printf("%d\n",(x&1)&&(z2));}A.0B.1C.2D.3
下面程序的结果【】。 include int f(int); void main() { int x=1,i; for (i=0; i 下面程序的结果【 】。include<iostream.h>int f(int);void main() {int x=1, i;for (i=0; i<3; i++)cout<<f(x)<<‘ ’ ;cout<<end1;}int f(int x){int y=1;static int z=3y++;z++;return (x+y+z);}
已知C源程序如下: include include void reverse(char S[]){ int C,i,J; f 已知C源程序如下:include<stdio. h>include<string. h>void reverse(char S[]){int C,i,J;for(i=0,j=strlen(s)-1;i<j;i++,j++){c=s[i];s[i]=s[j];s[j]=c;}}void getHex(int number,char s[]){int I;i=0;while(number>0){if(number%16<10)s[i++]=number%16+'0';elseswitch(number%16){case 10:s[i++]='A';break;case 11:s[i++]='B';break;case 12:s[i++]='C';break;case 13:s[i++]='D';break;case 14:s[i++]='E';break;case 15:s[i++]='F';break;default:printf("Error");break;}number/=16;}s[i]:'\o';reverse(s);}int main(){unsigned int number;int i=0:char s[50];printf("%s","please input number;\n");scanf("%d",&number):getHex(number,s);i=0;while(s[i])printf("%c",s[i++]);return 0;}画出程序中所有函数的控制流程图。
以下程序的输出结果是_______。 main() {union { char i[2]; int k; }r; r.i[0]=2; r.i[1]=0; printf("%d\n",r.k); }A.2B.1C.0D.不确定
已知字符0的ASCⅡ码为十六进制数30,下面程序的输出是______。 main() { int i; union{unsigned char c;unsigned int i[4];}z; z.i[0]=0x39;z.i[1]=0x36; printf("%d\n",z.c); }A.56B.57C.58D.59
已知字符'0'的ASCII码的十进制数为48,并且数组的第0个元素在低位,有以下程序includema 已知字符'0'的ASCII码的十进制数为48,并且数组的第0个元素在低位,有以下程序 #include<stdio.h> main() { union{int i[2];long k:char c[4];}r,*s=r; s->i[0]=0x39;s->i[1]=0x38;printf("%c\n",s->c[0]); } 程序运行后的输出结果是 ( )A.39B.9C.38D.8
下列程序的输出结果是______。 main() { union} int a[2]; long k; char c[4]; }un,*sp=un; sp->a[0]=0x39; sp->a[1]=0x38; printf("%1x\n",sp->k); }A.3938B.3839C.390038D.380039
字符‘0’的ASCⅡ码的十进制数为48,且数组的第0个元素在低位,则以下程序的输出结果是______。 #include<stdio.h> main() { union{int i[2];long k;char c[4];}r,*s=r; s->i[0]=0x39; s->i[1]=0x38; printf("%c\n",s->c[0]); }A.39B.9C.38D.8
请补充函数fun(),该函数的功能是:把从主函数中输入的由数字字符组成的字符串转换成—个无符号长整数,并且逆序输出。结果由函数返回。例如,输入: 1 2 3 4 5 6,结果输出:6 5 4 3 2 1。注意:部分源程序给出如下。请勿改动主函数main和其他函数中的任何内容,仅在函数fun()的横线上填入所编写的若干表达式或语句。试题程序:include<conio.h>include<stdio.h>include<string.h>unsigned long fun(char *S){unsigned long t=0;int k;int i=0;i=strlen(S);for(【 】;i>=0;i--){k=【 】;t=【 】;}return t;}main(){char str[8];clrscr();printf("Enter a string made up of'0'to'9'digital character:\n");gets(str);printf("The string iS:%S\n",str);if(strlen(str)>8)printf("The string is too long!");elseprintf("The result:%lu\n",fun(str));}
有以下程序:main(){ union{ unsigned int n; unsigned char c; }u1; u1.c='A'; printf("%c\n",u1.n);}执行后输出结果是( )。A.产生语法错B.随机值C.AD.65
若输入173253,则以下程序的运行结果为______。main(){ unsigned a; int n1,n2; scanf("%o",a); printf("%o",getbits(a,4,8));}getbits(value,n1,n2)unsigned value;int n1,n2;{ unsigned z; z=~0; z=(z>>n1)(z<<(16-n2)); z=valuez; z=z>>(16-n2); return(z);}A.173253B.6C.8D.173
已知字符0的ASCII码为十六进制的30,现有程序如下:includemain(){union{ unsigned char 已知字符0的ASCII码为十六进制的30,现有程序如下: #include <stdio.h> main() { union{ unsigned char c; unsigned int i[4]; }z; z.i[0]=0x39; z.i[1]=0x36; printf("%c\n",z.c); } 此程序的输出结果是( )。A.6B.9C.0D.3
阅读以下函数说明和C语言函数,将应填入(n)处的字句写在对应栏内。【函数2.1】void sort(char *s,int num){int i,j--num;char t;while(j-->1)for(i=0;i<j;i++)if(s[i]>s[i+1]){t=s[i];s[i]=s[i+1];s[i+1]=t;}void main(){char *s="CEAedea";sort(s,5);printf("%s",s);}上述程序的结果是(1)【函数2.2】void main(){ union {int ig[6];Char s[12];} try;try. ig[0]=0x4542; try.ig[1]=0x2049;try. ig[2]=0x494a; try.ig[3]=0x474e;try. ig[4]=0x0a21; try.ig[5]=0x0000;pintf("%s",try, s);}上述程序的结果是(2)【函数2.3】void main(){ char *letter[5]= { "ab","efgh","ijk","nmop","st"};char **p;int i;p=letter;for(i=0;i<4;i++) .printf("%s",p[i]);}上述程序的结果是(3)【函数2.4】main(){int i=4,j=6,k=8,*p=I,*q=j,*r=k;int x,y,z;x=p==i;y=3*-*p/(*q)+7;z=*(r=k)=*p**q;printf("x=%d,y=%d,z=%d",x,y,z);}上述程序的结果是(4)【函数2.5】int a[]={5,4,3,2,1 };void main(){int i;int f=a[0];int x=2;for(i=0;i<5;i++)f+=f*x+a[i];printf("%d",f);}上述程序的结果是(5)
下面程序的输出结果是( )。 main() { int i=1,p; p=f(i,++i); printf("%d",p); } int f(int a, int b) { int C; if(a>b) C=1; else if(a==b)C=0; else C==-1; return (C); }A.-1B.0C.1D.2
下面程序的输出结果是( )。 #include "stdio.h" fun (x int x { int y=0; static int z=5; z=x++,y++; return(Z); } main() { int a=4,i,j; for(i=0;i<2;i++) j=fun(a++); printf("%d",j); }A.0B.3C.4D.5
下面程序输出的结果是()。includeusing namespace std;int fuc (char *x);int main(){ 下面程序输出的结果是( )。 #include<iostream> using namespace std; int fuc (char *x); int main(){ cout<<fuc("hello")<<endl; return 0; } int fuc(char *x){ char *y=x; while(*y! ='\0')y++; return(y-x); }A.5B.6C.0D.语法错误,不能输出结果
若输入000051,下列程序的运行结果为______。 main(){ unsigned int a; scanf("%o",a); printf("%o\n",getbits(a));}getbits(value)unsigned int value;{ int i,j,m,n; unsigned int z,a,q; z=0; for(i=1;i<=15;i+=2) { q=1; for(j=1;j<=(16-i-1)/2;j++) q=q*2; a=value>>(16-i); a=a<<15; a=a>>15; z=z+a*q; } return(z);}A.6B.51C.51D.10
下列程序的输出结果是______。include main(){union {int k;char i[2]; }*S,a; s= 下列程序的输出结果是______。#include <stdio.h>main(){ union { int k; char i[2]; } *S,a; s=a; s->i[0]=0x39; s->i[1]=0x38; printf("%x\n",s->k);}A.3839B.3938C.380039D.390038
有以下程序:includeunion pw{int i; char ch[2]; } a;main(){a.ch[0]=13; a.ch[1]=0; 有以下程序: #include <stdio.h> union pw { int i; char ch[2]; } a; main() { a.ch[0]=13; a.ch[1]=0; printf("%d\n",a.i); } 程序的输出结果是(注意:ch[0]在低字节,ch[1]在高字节)( )。A.13B.14C.208D.209
有以下程序 main() { union{ unsigned int n; unsigned char C; }ul; u1.C='A'; printf("%c\n",u1.n); } 执行后输出结果是A.产生语法错B.随机值C.AD.65
阅读以下代码,回答问题:1至问题3 ,将解答填入答题纸的对应栏内。 【代码1】 includestdio.h void swap(int x, int y) { int tmp =x; x= y; y= tmp; } int maim() { int a= 3, b= 7; printf(a1= %d b1=%d\n,a,b); Swap( a, b); Printf(a2 = %d b2=%d\n,a,b); return 0; } 【代码2】 includestdio.h define SPACE //空格字符 Int main() { char str[128] = Nothing is impossible! ; int i,num =0,wordMark=0; for(i=0;str[i];i++) If(str[i]==SPACE) WordMark=0; else If(wordMark=0){ wordMark=1; num++; } Printf(%d/n,num) return 0; } 【代码3】 includestdio.h define SPACE //空格字符 int countStrs(char *); int main() { char str[128] = Nothing is impossible! ; Printf(%d/n,(1)(str)) return 0; } int countStrs(char *p) { int num=0, wordMark= 0; for(;(2); p++) { If((3)==SPACE) wordMark= 0; else if( !wordMark ) { wordMark = 1; ++num } } return (4) ; }【问题1】(4分) 写出代码1运行后的输出结果。 【问题2】(3分) 写出代码2运行后的输出结果。 【问题3】(8分) 代码3的功能与代码2完全相同,请补充3中的空缺,将解答写入答题纸的对应栏内。