有以下程序: include include usingnamespacestd; intmain() {intarrays有以下程序: #include <iostream> #include <cstdlib> using namespace std; int main() { int arraysize; int *array; cout<<"Please input the size of the array:"; cin>>arraySiZe; array=new int[arraysize

题目
有以下程序: include include usingnamespacestd; intmain() {intarrays

有以下程序: #include <iostream> #include <cstdlib> using namespace std; int main() { int arraysize; int *array; cout<<"Please input the size of the array:"; cin>>arraySiZe; array=new int[arraysize]; if(array==NULL) { cout<<"allocate Error\n"; exit(1); } for(int i=0;i<arraysize;i++) array[i]=i*i; int j; cout<<"which element you want to check:"; cin>>j; cout<<array[j]<<end1; return 0; } 执行程序输入:10<空格>5,则输出结果为( )。

A.allocate Error

B.1

C.0

D.25


相似考题
更多“有以下程序: #include <iostream> #include <cstdlib> usingnamespacestd; intmain() {intarrays ”相关问题
  • 第1题:

    有以下程序: include using namespace std; int main() {int x;for(int i=1;i<=100;

    有以下程序: #include <iostream> using namespace std; int main() { int x; for(int i=1;i<=100;i++) { x=i; if (++x%2==0) if (++x%3==0) if (++x%7==0) cout<

    A.39,81

    B.42,84

    C.26,68

    D.28,70


    正确答案:D
    解析:程序最后输出的x值所满足的条件为:x本身能被7整除,(x-1)能被3整除,(x-2)能被2整除。在1~100之间满足条件的x值是28和70。

  • 第2题:

    有以下程序: include include using namespace std; int main() {char arr[

    有以下程序: #include<iostream> #include<string> using namespace std; int main() { char arr[2][4]; strcpy(arr[0],"you"); strcpy(arr[1],"me"); arr[0][3]='&'; cout<<arr[0]<<end1; return 0; } 执行后的输出结果是( )。

    A.you&me

    B.you

    C.me

    D.err


    正确答案:A
    解析:本题考核字符串函数的使用。主函数中,首先定义了千个二维字符数组art。语句“strcpy(arr,"you");”中的alt代表二维字符数组的首元素地址,此语句的作用是将字符串“you”复制到arr数组的前4个元素中,第4个元素的值为'\0'。语句“strcpy(arr[1],"me");”的作用是把字符串“me”赋值到arr数组的第2行。语句“arr[0][3]='及';”的作用是用字符'&'取代了原来arr[0][3]中的字符'\0'。所以程序最后输出you&me。

  • 第3题:

    阅读以下程序,给出运行结果 #include <iostream> #include <cstring> using namespace std; int main() { string str="I love China!"; cout << str; return 0; }


    emoclew emoclew

  • 第4题:

    有以下程序:include include using namespace std;int main ( ){ ofstream

    有以下程序: #include <iostream> #include <fstream> using namespace std; int main ( ) { ofstream ofile; char ch; ofile.open ("abc.txt"); cin>>ch; while (ch!='#' ) { cin>>ch; ofile.put(ch);

    A.程序编译时出错

    B.abc#

    C.abc

    D.#


    正确答案:C
    解析:本题程序的功能是将从键盘终端输入的内容存储到指定的文件中。

  • 第5题:

    有以下程序:include include using namespace std;int main (){ char s[]="

    有以下程序: #include <iostream> #include <string> using namespace std; int main () { char s[]="\n123\\"; cout<<strlen (s) <<", "<<sizeof (s) <<end1; return 0; }

    A.赋初值的字符串有错

    B.6,7

    C.5,6

    D.6,6


    正确答案:C
    解析:本题考核字符串的长度和字符型数组所占的字节数。本题在定义字符数组时没有定义数组长度,但赋给数组初值,初值的个数即为数组的长度。故数组长度为6(包括'\0')。字符串的长度为有效字符的个数,为5。所以程序最后输出5,6。