以下代码的运行结果是 char name[8]={‘s’,’t’,’0’,’t’,’n’,’g’,'0'}; name[2]=‘b’; name[5]=0; puts(name);A.stB.strbnC.stbtnD.stbtng
以下代码的运行结果是 char name[8]={‘s’,’t’,’0’,’t’,’n’,’g’,'0'}; name[2]=‘b’; name[5]=0; puts(name);
A.st
B.strbn
C.stbtn
D.stbtng
参考答案和解析
stbtn
相关考题:
有以下结构体说明、变量定义和赋值语句struct STD{ char name[10];int age;char sex;} s[5],*ps;ps=s[0];则以下 scanf 函数调用语句中错误引用结构体变量成员的是A)scanf("%s",s[0].name);B)scanf("%d",s[0].age);C)scanf("%c",(ps-sex));D)scanf("%d",ps-age);
( 27 )有如下程序:#include iostreamusing namespace std;class Toy{public:Toy(char* _n) { strcpy (name,_n); count++;}~Toy(){ count--; }char* GetName(){ return name; }static int getCount(){ return count; }private:char name[10];static int count;};int Toy::count=0;int mail(){Toy t1("Snoopy"),t2("Mickey"),t3("Barbie");coutt1.getCount()endl;return 0;}运行时的输出结果是A ) 1B ) 2C ) 3D )运行时出错
( 29 )有如下程序:#includeiostreamusing namespace std;class Name{char name[20];public:Name(){strcpy(name,""); cout'?';}Name(char *fname)){strcpy(name,fname); cout'?';}};int main(){Name names[3]={Name(" 张三 "),Name(" 李四 ")};Return 0;}运行此程序输出符号?的个数是A ) 0B ) 1C ) 2D ) 3
( 13 )有如下程序:#include iostreamusing namespace std;class GrandChild{public:GrandChild(){ strcpy (name,"Unknown"); }const char * getName()const { return name; }virtual char * getAddress()const=0;private:char name[20];};class GrandSon : public GrandChild{public:GrandSon{char *name} {}Char * getAddress() const { return "Shanghai";}};int main(){GrandChild *gs=new GrandSon("Feifei");coutgs-getName()" 住在 "gs-getAddress()endl;delete gs;return 0;}运行时的输出结果是 【 13 】 。
有以下程序#include stdio.h#include string.htypedef struct{ char name[9]; char sex; float score[2]; }STU;void f(STU a){ STU b={"Zhao",′m′,850,900}; int i;strcpy(a.name,b.name);a.sex=b.sex;for(i=0;i2;i++) a.score[i]=b.score[i];}main(){ STU c={"Qian",′f′,95.0,92.0};f(c);printf("%s,%c,%2.0f,%2.0f\n",c.name,c.sex,c.score[0],c.score[1]);}程序的运行结果是A.Qian,f,95,92B.Qian,m,85,90C.Zhao,f,95,92D.Zhao,m,85,90
如下程序的输出结果是______。 include using namespace std; class Pet{ char nam 如下程序的输出结果是______。include<iostream>using namespace std;class Pet{char name[10];public:Pet(char*nanle){strcpy(this->name,name);}const char*getName( )const{return name;}virtual void call( )eonst=0;};class Dog:public Pet{public:Dog(char*name):Pet(name){ }void call( )eonst{cout<<"汪汪叫";}};class Cat:public Pet{public:Cat(char*name):Pet(name){ }void call( )const{eout<<"喵喵叫";}};int main( ){Pet*petl=new Dog("哈克"),*pet2=new Cat("吉米");eout<<petl->getName( );petl->call( );eout<<endl;cout<<pet2->getName( );pet2->call( );eout<<endl;return 0;}
有以下程序includestruct STU{char name[10];int num;};void f(char*name, intnum){s 有以下程序 #include <string.h> struct STU { char name[10]; int num; }; void f(char *name, int num) { struct STU s[2]={{"SunDan",20044},{"Penghua",20045}}; num=s[0].num; strcpy(name,s[0].name); } main() { struct STU s[2]={{"YangSan",20041},{"LiSiGuo",20042}},*p; p=s[1]; f(p->name,p->num); printf("%s %d\n",p->name,p->num); } 程序运行后的输出结果是A.SunDan 20042B.SunDan 20044C.LiSiGuo 20042D.YangSan 20041
阅读以下说明C++代码,将应填入(n)处的字句写在对应栏内。[说明]本程序实现了雇员信息管理功能,其中封装了雇员信息及其设置、修改、删除操作。已知当输入为“Smith 31 2960.0”时,程序的输出是:姓名:Smith 年龄:31 工资:2960姓名:Smith 年龄:31 工资:3500姓名:Mary 年龄:23 工资:2500[C++程序]include <iostream.h>include <string.h>class employee{char *name; //雇员姓名short age; //年龄float salary;//工资public:employee();void set_name(char *);void set_age(short a) {age=a;}void set_salary(float s) {salary=s;}(1);~ employee(){delete[] name;}};employee::employee() { name="";age=0;salary=0.0;void employee::set_name(char *n){ name=new char[strlen(n)+1];(2) (name,n);}void employee::print(){ cout<<"姓名":"<<name<<" 年龄:"<<agc<<" 工资:" <<salary<<endl;}void main(){ char *na;short ag=0;float sa=0;(3);na=new char[10];cin>>na>>ag>>sa;emp.set_name(na);emp.set_age(ag);emp.set_salary(sa);emp.print();(4) (3500.0);emp.print();(5);emp.set_name("Mary");emp.set_age(23);emp.set_salary(2500.0);emp.print();}
有如下程序:#includeiostreamusing flamespace std;class Name{char name[20];public:Name(){strcpy(name,“”); cout‘?’;}Name(char*fname){strcpy(name,fname); cout‘?’;}};int main(){Name names[3]={Name(”张三”),Name(”李四”)};return 0;}运行此程序输出符号?的个数是A.0B.1C.2D.3
若有以下说明,则能打印出“Yu”的语句是______。 struct samp { char name[10]; int number; }kk[3]={{"WarBin",1},{"LiYu",2},{"LuHui",3}}; struct samp*str[3]; str[0]=kk[0];str[1]=kk[1];str[2]=kk[2];A.printf("%s\n",str[1].name[2]);B.printf("%s\n",str[1]->name+2);C.printf("%s\n",str[2].name[2]);D.printf("%s\n",str[2]->name+2);
有以下程序: include struct STU (char name[10]; int num; }; 有以下程序: #include <string.h> struct STU (char name[10]; int num; }; void f(char *name, int num) {struct STU s[2]={{"SunDan",20044}.{"Penghua",20045}}; num=s[0].num; strcpy(name,s[0].name); } main() {struct STU s[2]={{"YangSall",20041},{"LiSiGao",20042}},*p;p=s[1]; f(p->name,p->num); printf("%s%d\n",p->name,p->num); } 程序运行后的输出结果是 ______。A.SunDan 20042B.SunDan 20044C.LiSiGuo 20042D.YangSan 20041
有如下程序:#includeiostreamusing namespace std;class Toy{public:Toy(char*_n){strcpy(name,_n);count++;}~Toy()}count--;}char*GetName(){return name;}static int getCount(){return count;}private:char name[10];static int count;};int Toy::count=O:int main(){Toy tl(“Snoopy”),t2(“Mickey”),t3(“Barbie”);coutt1.getCount()endl;return O:}运行时的输出结果是A.1B.2C.3D.运行时出错
有如下程序: include using namespace std; class Pet{ char name[10]; public: Pet(c 有如下程序:include<iostream>using namespace std;class Pet{char name[10];public:Pet(char*name){strcpy(this->name,name);}const char*getName()const {return name;}virtual void call()const=0;};class Dog:public Pet{public:Dog(char*name):Pet(name){}void call()const{cout<<"汪汪叫":}};class Cat:public Pet{public:Cat(char*name):Pet(name){}void call()const{cout<<"喵喵叫";}};int main(){Pet*pet1=new Dog("哈克"),*pet2=new Cat("吉米");cout<<pet1->getName();pet1->call();cout<<end1;cout<<pet2->getName();pet2->call();cout<<end1;return 0;}程序的输出结果是______。
以下选项中,合法的是( )。A.char str3[]={d,e,b,u,g,\0};B.char str4;str4="hello world";C.char name[10];name="china";D.char strl[5]="pass",str2[6];str2=strl;
有以下程序 include main() { struct STU{char name[9];char sex;double 有以下程序 #include <stdio.h> main() { struct STU{char name[9];char sex;double score[2];}; sturt STU a={"Zhao" ,'m',85.0,90.0},b={"Qian" ,'f,95:0,92.0}; b=a; printf("%s,%c,%2.0f,%2.0f\n",b.name,b.sex,b.score[0],b.score[1]); } 程序的运行结果是______。A.Qian,f,95,92B.Qian,85,90C.Zhao,f,95,92D.Zhao,m,85,90
有如下程序:includeusing namespace std;class Name{char name[20];public:Name( ){s 有如下程序: #include<iostream> using namespace std; class Name{ char name[20]; public: Name( ){strepy(name," ");tout<<'?';} Name(char*fname){strcpy(name,fname);cout<<'?';} }; int main( ){ Name name[3]={Name("张三"),Name("李四")}; return 0; } 运行此程序输出符号“?”的个数是A.0B.1C.2D.3
若有如下程序: main() { char a[3][5] = {"name","age","sex"},n; for(n=0;n<3;n++) printf("%s\n",a[n]);} 则程序执行后的输出结果是( )。A.nameagesexB.nameC.nameD.name agexex ge age sex x sex
有如下程序: #includeiostream usingnamespacestd; className{ charname[20]; public: Name( ){ strcpy(name,"");cout?; } Name(char*fname){ strcpy(name,fname);cout?; } }; intmain( ){ Namenames[3]={Name(”张三”),Name(”李四”)); return0; } 运行此程序输出符号?的个数是( )。A.OB.1C.2D.3
有如下程序:#includeiostreamusingnamespacestd;classToy{public:Toy(char*_n){strcpy(name,_n);count++;)~Toy( ){count一一;)char*GetName( ){returnname;}staticintgetCount( ){returncount;)private:charname[10];staticintcount;};intToy::count=0;intmain( ){Toyt1(snoopy),t2(Mickey),t3(Barbie);toutt1.getCount( )endl:return0;)运行时的输出结果是( )。A.1B.2C.3D.运行时出错
有以下程序: #includestdio.h struct stu { int num;char name[l0];int age;}; void fun(struct stu*p) { printf("%s\n",p-name);} main( ) { struct stu x[3]={{01,"Zhang",20),{02,"Wang",l9},{03,"Zha0",l8}}; fun(x+2); } 程序运行后的输出结果是( )。A.ZhangB.ZhaoC.WangD.19
有如下程序:includeusing namespace std;class Toy{public:Toy(char*_n){strcpy(name 有如下程序: #include<iostream> using namespace std; class Toy{ public: Toy(char*_n){strcpy(name,_n);count++;} ~Toy(){count--;} char*GetName( ){return name;} static int getCount( ){return count;} private: char name[10]; static int count; }; int Toy::count=0: int main( ){ Toy tl("Snoopy"),t2("Mickey"),t3("Barbie"); cout<<t1.getCount( )<<endl; return 0; } 程序的输出结果是A.1B.2C.3D.运行时出错
有以下程序 include include typedef stmct{ char name[9];char sex;flo 有以下程序#include <stdio.h>#include <string.h>typedef stmct{ char name[9];char sex;float score[2];}STU;void f(STU a){ STU b={"Zhao",'m',85.0,90.0}; int i;strcpy(a.name,b.name) ;a.sex=b.sex;for(i=0;i<2;i++) a.score[i]=b.score[i];main( ){ STU c={"Qian",'f',95.0,92.0};f(c);printf("%s,%c,%2.0f,%2.0f\n",c.name,c.sex,c.score[0],c.score[1]) ;}程序的运行结果是A.Qian,f,95,92B.Qian,m,85,90C.Zhao,f,95,92D.Zhao,m,85,90
有以下程序:includeinclude struct STU {char name[10];int hum;};void f( 有以下程序:#include <stdio.h>#include <strine.h> struct STU { char name[10]; int hum;};void f(char * name,iht num){ struct STU s[2] = {{ "SunDan" ,20044} , {" Penghua" ,20045}}; num= s[0]. nnm; strepy(name,s[0], name);}main( ){ struct STU s[2] = {{"YangSan" ,20041 }, { "LiSiGao" ,20042}}, * P; p = s[1]; f(p->name,p->hum); printf("% s %d \n" ,p-> name,p->num);}程序运行后的输出结果是( )。A.SunDan 20042B.SunDan 20044C.LiSiGuo 20042D.YangSan 20041
有以下程序:includeincludetypedef struct{char name[9];char sex;float s 有以下程序: #include <stdio.h> #include <string.h> typedef struct{char name[9];char sex;float score[2]}STU; STU f(STU A) {STU b={"Zhao",'m',85.0,90.0}; int i; strcpy(a.name,b.namC) ; a.sex=b.sex; for(i=0;i<2;i++) a.score[i]=b.score[i]; return a; } main() {STU c={"Qian",'f',95.0,92.0},d; d=f(C) ; pintf("%s,%c,%2.of.%2.of\n",d.name,d.sex,d.score[0],score[1]); } 程序的运行结果是( )。A.Qian,f,95,92B.Qian,m,85,90C.Zhao,m,85,90D.Zhao,C95,92
单选题有以下程序:#includemain(){ charname[10]={'S','T','R'}; name[2]='#'; name[6]=0; printf(%s,name);}程序运行后的输出结果是( )。AST#BSTR#CSTR#0DSTR0
单选题有如下程序:#include main(){ char name[10] = {'S','T','R','I','N','G'}; name[3]='E'; name[5]=0; printf(%s,name);}程序运行后的输出结果是( )。ASTRENGBSTRIEGCSTRENDSTREN0
单选题有以下程序:#include #include typedef struct{ char name[10]; char sex; int age;}STU;void fun(STU *t){ strcpy((*t).name,Tong); (*t).age++;}main(){ STU s[2] = {Hua, 'm', 18, Qin, 'f', 19}; fun(s+1); printf(%s,%d,%s,%d, s[0].name, s[0].age, s[1].name, s[1].age);}程序运行后的输出结果是( )。AHua,18,Tong,20BHua,18,Qin,19CTong,19,Qin,19DHua,19,Tong,19
单选题有以下程序:#include #include struct S{ char name[10];};main(){ struct S s1,s2; strcpy(s1.name,XXX); strcpy(s2.name,=); s1=s2; printf(%s,s1.name);}程序运行后的输出结果是( )。A=BXXXC=XXDX=