题目
分析下面的程序:
void GetMemory(char **p,int num)
{
*p=(char *)malloc(num);
}
int main()
{
char *str=NULL;
GetMemory(&str,100);
strcpy(str,"hello");
free(str);
if(str!=NULL)
{
strcpy(str,"world");
}
printf("\n str is %s",str);
getchar();
}
问输出结果是什么?希望大家能说说原因,先谢谢了
第1题
A. 17
B. 16
C. 13
D. 14
第2题
下面的程序输出的结果是()。 #include <iostream> using namespace std; void main(){ int a=2; int &c=a; a++; cout<<c; }
A.2
B.3
C.4
D.*a
第5题
下面的程序段违反了算法的(52)原则。 void sam() {int n=2: while (!odd (n)) n+=2; printf (n); }
A.有穷性
B.确定性
C.可行性
D.健壮性
第6题
A. 打印输出0
B. 打印输出1
C. 打印输出2
D. 打印输出3
第7题
执行下面的程序段,输出结果为______。
public class Q
{
public static void main(String argvr))
{
int anar[]=new int[5];
System.out.println(anar[0]);
}
}
第8题
下面的程序输出结果是()。 #include<iostream> using namespace std; void add() { static int x; x++; cout<<x<<''; } int main() { for(int i=0;i<3;i++) add(); return 0; }
A.111
B.123
C.222
D.333
第9题
下面的程序输出结果是 ______。 #define r 16 #if r==16 void p(int a) { printf("%x",a) ; } #else void p(int a) { printf("%d",a) ; } #endif main() { p(32); }
A.32
B.20
C.编译时错误
D.运行时错误
第10题
下面的程序段违反了算法的(2)原则。 Void sam() {int n=2; while(!odd(n)) n+=2 printf(n); }
A.有穷性
B.确定性
C.可行性
D.健壮性
第11题
下面的程序中,错误的语句是()。 ①inClude
②void main ③{ ④ int *p=new int[1]; ⑧P=9; ⑥cout<<.*P<<endl; ⑦delete[]p; ⑧}
A.④
B.⑤
C.⑥
D.⑦
为了保护您的账号安全,请在“赏学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!