重要提示:请勿将账号共享给其他人使用,违者账号将被封禁!
查看《购买须知》>>>
首页 > 干部教育培训
网友您好,请在下方输入框内输入要搜索的题目:
搜题
拍照、语音搜题,请扫码下载APP
扫一扫 下载APP
题目内容 (请给出正确答案)
[单选题]

有以下程序#include<string.h>main(){ char p[]={′a′, ′b′, ′c′},q[10]={ ′a′, ′b′, ′c′};printf("%d%d\n",strlen(p),strlen(q));}以下叙述中正确的是

A.在给p和q数组置初值时,系统会自动添加字符串结束符,故输出的长度都为3

B.由于p数组中没有字符串结束符,长度不能确定,但q数组中字符串长度为3

C.由于q数组中没有字符串结束符,长度不能确定,但p数组中字符串长度为3

D.由于p和q数组中都没有字符串结束符,故长度都不能确定

答案

A、在给p和q数组置初值时,系统会自动添加字符串结束符,故输出的长度都为3

解析:解析:在给p和q数组赋初值时,系统会自动添加字符串结束符,从题目中可以看出数组p和q都有3个字符,所以长度均为3。

更多“有以下程序 #include<string.h> main() {char p[]={′a′, ′b′, ′c′},q[10]={ ′a′, ′b′, ′c′”相关的问题

第1题

以下程序运行后的输出结果是【 】。 include <stdio, h> include <string, h> main() { char

以下程序运行后的输出结果是【 】。 include <stdio, h> include <string, h> main() { char ch[] ="abc".,x[3] [4]: int i: for(i=0;i<3:i ++) strcpy(x[i] ,ch): for(i =0;i<3:i++) printf("% s" ,&x[i] [i]); printf(" \n" ) }

点击查看答案

第2题

以下程序的功能是找出三个字符串中的最大串。 【 】 include<stdio.h> main()

以下程序的功能是找出三个字符串中的最大串。 【 】 include<stdio.h> main() { int i; char string[20],str[3][20]; (i=0;i<3;i++)gets(【 】 ); if(strcmp(str,str[0],str[1]>0)strcpy(string,str[0]); else strcpy(string,str[1]); if(strcmp(str[2],string)>【 】 )srtcpy(string,str[2]); printf("The largest string is\n%s\n",string); }

点击查看答案

第3题

给定以下程序段insert code public class foo {public static void main (String[] args) thro

给定以下程序段insert code public class foo {public static void main (String[] args) throws Exception {printWriter ut = new PrintWriter (new java.io.outputStreamWriter (System.out), true) ;out.printIn(“Hello”);}要使程序能正确运行,在insert code处必须添加()语句。

A、include java.io.OutputStreamWriter;

B、import java.io.OutputStreamWriter;

C、import java.io.PrintWriter;

D、include java.io.PrintWriter

点击查看答案

第4题

编写类String 的构造函数、析构函数和赋值函数和测试程序。已知类String 的原型为:#include#in

编写类String 的构造函数、析构函数和赋值函数和测试程序。

已知类String 的原型为:

#include

#include

class String

{public:

String(const char *str=NULL); // 普通构造函数

String(const String &other); // 拷贝构造函数

~String(); // 析构函数

String & perator=(const String &other); // 赋值函数

void show()

{cout<< m_data<< endl;

}

private:

char *m_data; // 用于保存字符串

};

点击查看答案

第5题

下列程序用来将从键盘上输入的2个字符串进行比较,然后输出2个字符串中第1个不相同字符的ASCII码
之差。例如,输入的2个字符串分别为abcdef和abceef,则输出为-1。 include main () { char str [100], str2 [100], c; int i,s; printf("\n input string 1:\n"); gest(str1); printf("\n input string 2:\n"); gest(str2); i=0; while((strl[i]==str2[i]&&(strl[i]!=【 】)) i++; s=【 】; printf(.%d\n",s);

点击查看答案

第6题

有以下程序 include<stdio.h> main() {chara=4; printf(%dha,a=a<<1); )A.8B.16C.40D.4

有以下程序 include<stdio.h> main() {chara=4; printf(%dha,a=a<<1); )

A.8

B.16

C.40

D.4

点击查看答案

第7题

有以下程序 yoidfun(char*S){ chara[10]; strcpy(a,STRING); S=a;} main(){ char*p=PR

有以下程序 yoidfun(char*S){ chara[10]; strcpy(a,STRING); S=a;} main(){ char*p=PROGRAM; fun(P); printf(%s\n,p);) 程序运行后的输出结果是(此处□代表空格)

A.STRNG□□□□

B.PROGRAM

C.STRING□□□

D.STRING

点击查看答案

第8题

有以下程序 include<stdio.h> main(){ inta=3; printf(%d\n,(a+=a-=a*a));} 程序运行后

有以下程序 include<stdio.h> main(){ inta=3; printf(%d\n,(a+=a-=a*a));} 程序运行后的输出结果是

A.9

B.0

C.3

D.-12

点击查看答案

第9题

有以下程序: include <stdio.h> main() { char c; while((c=getchar())!=?)

有以下程序: include <stdio.h> main() { char c; while((c=getchar())!=?) putchar(--c); } 程序运行时,如果从键盘输入Y?N?<回车>,则输出结果为【 】。

点击查看答案

第10题

有以下程序(strcat函数用以连接两个字符串) include<stdio.h> include<string.h> main()

有以下程序(strcat函数用以连接两个字符串) include<stdio.h> include<string.h> main() {chara[20]=abcD\OEFG\O,b[]=%s\n; strcat(a,b);printf(%s\n,a); } 程序运行后的输出结果是

A.abcDE\0FG\0UK

B.abcDUK

C.UK

D.EFGUK

点击查看答案

第11题

有以下程序: include<stclio.h> main() { char c; while((c=getchar())!=?)pu

有以下程序: include<stclio.h> main() { char c; while((c=getchar())!=?)putchar(--c); } 程序运行时,如果从键盘输入:Y?N?<回车>,则输出结果为【 】。

点击查看答案
下载APP
关注公众号
TOP
重置密码
账号:
旧密码:
新密码:
确认密码:
确认修改
购买搜题卡查看答案 购买前请仔细阅读《购买须知》
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《服务协议》《购买须知》
立即支付 系统将自动为您注册账号
已付款,但不能查看答案,请点这里登录即可>>>
请使用微信扫码支付(元)

订单号:

遇到问题请联系在线客服

请不要关闭本页面,支付完成后请点击【支付完成】按钮
遇到问题请联系在线客服
恭喜您,购买搜题卡成功 系统为您生成的账号密码如下:
重要提示:请勿将账号共享给其他人使用,违者账号将被封禁。
发送账号到微信 保存账号查看答案
怕账号密码记不住?建议关注微信公众号绑定微信,开通微信扫码登录功能
请用微信扫码测试
优题宝