有以下程序#includevoid main(){int a ;scanf("%d",&a);if(a >= 0){if
A.-11 is a positive odd number.
B.-11 is a negative odd number.
C.-11 is a positive even number.
D.11 is a negative even number.
A.-11 is a positive odd number.
B.-11 is a negative odd number.
C.-11 is a positive even number.
D.11 is a negative even number.
第1题
#include <stdio.h>
#include <stdlib.h>
void getmemory(char *p)
{
p=(char *) malloc(100);
strcpy(p,"hello world");
}
int main()
{
char *str=NULL;
getmemory(str);
printf("%s/n",str);
free(str);
return 0;
}
程序崩溃,getmemory中的malloc 不能返回动态内存, free()对str操作很危险
5.char szstr[10];
strcpy(szstr,"0123456789");
产生什么结果?为什么?
第2题
A.1,-1,3
B.0,0,3
C.0,-1,2
D.1,0,3
第3题
有以下程序
#include
main()
{
int y=9 ;
for(; y>0 ; y--)
if(y%3==0 ) printf("%d" , --y) ;}
程序的运行结果是_____
第4题
A.protected int ConstOver (){ }
B.private ConstOver (int z, int y, byte x) { }
C.public object ConstOver (int x, int y, int z) { }
D.public void ConstOver (byte x, byte y, byte z) { }
第5题
以下程序的功能是求两个非0整数相除的商和余数。程序有几处错误,试找出它们加以修改,并上机验证修改结果。 #include "iostream" using namespace std; int main() {int x,y,r1,r2; cin>>x>>y; if(x=0||y=0) cout<<”input else { if(x> y) r1=x/y; r2=x%y; else r1=y/x; r2=y%x; } cout<<”商=> <<” 余数="”<"> < <endl; system("pause"); return 0;>
第6题
改错:
#include <stdio.h>
int main(void) {
int **p;
int arr[100];
p = &arr;
return 0;
}
第7题
以下程序的输出结果是()
#include<stdio.h>
main()
{ unsigned short a=65537; int b;
printf("%d/n" ,b=a);
}
第8题
#include <stdio.h>
void foo(int m, int n)
{
printf("m=%d, n=%d\n", m, n);
}
int main()
{
int b = 3;
foo(b+=3, ++b);
printf("b=%d\n", b);
return 0;
}
第9题
A.Not equal
B.Equal
C.无输出
D.编译出错
第10题
class A
{
int a;
A(int b)
{a=b;}
void show()
{System.out.println(“a=”+a);}
}
public class Class1
{
public static void main (String args[])
{
A bj=new A(12345);
boolean b=false;
char ch=97;
obj.show();
System.out.println(“b=”+b+”/tch=”+ch);
}
}
第11题
写出以下程序的运行结果。public class Test2 {public static void main(String args[ ]){int i,j;int a[]={17,91,65,35,28};for (i = 0; i < a.length-1; i++ ) {int k = i;for(j = i; j < a.length; j++ )if (a[j]>a[k] )k = j;int temp =a[i];a[i] = a[k];a[k] = temp;}for (i =0; i<a.length; i++ )System.out.print(a[i]+" ");System.out.println();} }