更多"[单选题]阅读下面代码,输出结果为()
int main()
{
c"的相关试题:
[单选题]下面代码的输出结果为
int func(int x)
{
int countx =0;
while(x)
{
countx ++;
x = x&(x-1);
}
return countx;
}
int main()
{
cout<A.255
B.8
C.12
D.6
[简答题]以下程序段的输出结果是 。
Int main()
{ char s[]= "abcdefg";
s[3] ='\0';
cout << s;
return 0;
}
[单选题]以下程序段运行后的输出结果是( )。
Int main()
{ char str[][9]={"hello", "student", "computer"};
cout << str[1];
return 0;
}
A. h
B. hello
C. student
D. computer
[单选题]现在有如下程序
Int main()
{ char s[80];
int i,j;
gets(s);
for(i=j=0;s[i]!=′\0′;i++)
if(s[i]!=′H′) ______
s[j]=′\0′;
puts(s);
return 0;
}
这个程序段的功能是删除输入的字符串中字符′H′,则空线上应当填入的是( )。
A. s[j++]=s[i]; j++;
B. s[j]=s[i++]; j++;
C. s[j++]=s[i];
D. s[j]=s[i];
[单选题]请阅读下列代码:protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_CODE://标志符 if (resultCode == RESULT_OK) { strReturnData = data.getStringExtra("password"); mTextView2.setText("第二个Activity传回的password:" + strReturnData); } break; default: }}。onActivityResult的作用是什么()?
A.处理第一个Activity的运行数据
B.处理第一个Activity传递给第二个Activity的运行数据
C.处理第二个Activity的运行数据
D.处理第二个Activity传回给第一个Activity的运行数据
[单选题]阅读下列代码
public class Person{
static int arr[ ] = new int[10];
public static void main (String[] args) {
System.out.println(arr[9]);
}
}
该代码运行的结果是:
A.编译时将产生错误
B.编译时正确,运行时将产生错误
C.输出0
D.输出空
[单选题]有以下程序
Int main()
{ char a[]={ ′a′, ′b′, ′c′,′d′, ′e′, ′f′, ′g′,′h′,′\0′};
int i,j;
i=sizeof(a);
j=strlen(a);
cout << i << "," << j << endl;
Return 0;
}
程序运行后的输出结果是( )。
A. 9,9
B. 8,9
C. 1,8
D. 9,8
[多选题]下面代码实现了ListView的数据,请补全代码()?private int[] iPic = {R.drawable.door, R.drawable.lib, R.drawable.science, R.drawable.rest, R.drawable.lake, R.drawable.medium, R.drawable.night}; private String[] strName = {"大门", "图书馆", "科技楼", "宿舍楼", "天鹅湖", "体育场", "夜景"}; private String[] strContent = {"美丽大运村", "美丽图书馆", "美丽科技楼", "美丽宿舍楼",
"美丽天鹅湖","美丽体育场", "美丽夜景"};
private ArrayList mArrayList;
private void initData() { mArrayList=new ArrayList<>(); for (int i=0;iA.mItemBean.setiPic(iPic[i]);
B.mItemBean.setStrName(strName[i]);
C.map.put("content",strContent[i]);
D.mItemBean.setStrContent(strContent[i]);
[多选题] 下面代码实现了ListView的数据,请补全代码()?private int[] iPic = {R.drawable.door, R.drawable.lib, R.drawable.science, R.drawable.rest, R.drawable.lake, R.drawable.medium, R.drawable.night}; private String[] strName = {"大门", "图书馆", "科技楼", "宿舍楼", "天鹅湖", "体育场", "夜景"}; private String[] strContent = {"美丽大运村", "美丽图书馆", "美丽科技楼", "美丽宿舍楼",
"美丽天鹅湖","美丽体育场", "美丽夜景"};
private ArrayList
[简答题]完成下面输出字符串“world”的程序。
Int main( )
{ int i,j;
char c[]="hello world";
for(i=0;i<5;i++)
{ ;
cout << c[j];
}
return 0;
}
[单选题]下面代码的输出结果是:()
Public class Main {
Public static void main(String[] args) {
Int n1 = 1;
Int n2 = 2;
N1 = n1 + n2;
N2 = n1 - n2;
N1 = n1 - n2;
System.out.println(n1 + "," + n2);
}
}
A. 1,2
B. 2,1
C. 1,3
D. 3,2
[单选题]给出下面代码:
Public class Person{
Static int arr[] = new int[10];
Public static void main(String a[])
{
System.out.println(arr[1]);
}
}
哪个语句是正确的? ( )
A.编译时将产生错误;
B.输出零;
C.编译时正确,运行时将产生错误;
D.输出空。
[单选题]阅读以下代码,输出结果为()
class A
{
public:
virtual void a()=0;
virtual ~A(){}
};
class AA:public A
{
public:
void a()
{
cout<<"nihao 2\n";
}
~AA()
{
cout<<"delete AA \n";
}
};
class AAA:public AA
{
public:
void a()
{
cout<<"nihao 3 \n";
}
~AAA()
{
cout<<"delete AAA \n";
}
};
class B
{
public:
A *b(int kind)
{
if(kind == 1)
return new AA;
else
return new AAA;
}
~B()
{
cout<<"delete B\n";
}
};
int main()
{
B *bb = new B;
A *aa = bb->b(1);
aa->a();
aa = bb->b(2);
aa->a();
delete aa;
delete bb;
return 0;
}
A.
nihao2
nihao3
delete AA
delete AAA
delete B
B.
nihao3
nihao3
delete AAA
delete AA
delete B
C.
nihao2
nihao2
delete AAA
delete AA
delete B
D.
nihao2
nihao3
delete AAA
delete AA
delete B
[单选题]
(单选题)下面的代码输出的结果是()
Var name="Tom";
Function foo(){
Console.log(name);
Var name="Jerry";
Console.log(name);
}
Foo();
A.undefined
"Jerry"
B."Tom"
"Jerry"
C."Tom"
Undefined
D."Jerry"
"Jerry"
[单选题]阅读下马代码,运行结果为()
class cls
{
public:
int mi ;
cls(int i):mi(i)
{
mi = i;
cout<A.1
B.2
C.3
D.未知
[单选题]【单选题】
(单选题)下面的代码输出的结果是()
Var name="Tom";
Function foo(){
Console.log(name);
Var name="Jerry";
Console.log(name);
}
Foo();
A.undefined
"Jerry"
B."Tom"
"Jerry"
C."Tom"
Undefined
D."Jerry"
"Jerry"
[单选题]对于下面代码,描述正确的是
template
class A
{
public:
enum E{N = A::E::N * M};
};
template <>
class A<1>
{
public:
enum E{N = 1};
};
int main()
{
int a[A<4>::N];
return 0;
}
A.编译错误,定义数组时下标必须为常量
B.能正确编译,数组a大小为24
C.能正确编译,数组a大小为4
D.能正确编译,数组a大小为10
[简答题]下面程序的功能是输出数组s中最大元素的下标,请填空。
Int main( )
{ int k, p,s[]={1, -9, 7, 2, -10, 3};
for ( p=0, k =p; p< 6; p++)
if (s[p]>s[k]) ; //注意:不要在运算符前后加空格
cout << k;
return 0;
}