有以下程序: main() { int i=0, s=0; do{ if(i % 2) {i++; continue;} i++; s+=i; }while(i<7); printf("% d\n", s); } 执行后的输出结果是______。
A.16
B.12
C.28
D.21
A.16
B.12
C.28
D.21
第1题
有以下程序: int f(int n) { if(n ==1)return 1; else return f(n-1)+1; } main() { int i,j=0; for(i=1;i<3;i++) j+=f(i); printf("%d\n",j); } 程序运行后的输出结果是
A.4
B.3
C.2
D.1
第2题
A.0
B.10
C.30
D.64
第3题
A.2,-1
B.3,1
C.2,0
D.2,1
第4题
A.1,2,3
B.3,1,2
C.1,3,2
D.2,3,1
第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题
以下程序的计算结果是()。
class Test { public static void main(String[] args){int d=5;int
c=2;float x=d/c;System.out.println("x="+x);} }
第7题
写出以下程序的运行结果。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();} }
第8题
public class Class1
{
public static void main(String args[])
{
int n=6,sum=0;
for(int k=1;k<=n;k++)
{
if (n%k==0)
sum+=k;
}
System.out.println(sum);
}
}
第9题
class A{
int x=100;
}
class B extends A{
int x=200;
void prt(){
System.out.println("SubClass: "+x);
System.out.println("SuperClass: "+super.x);
}
public static void main(String args[]){
new B().prt();
}
}
第10题
有程序: main() { int x,i; for(i=1;i<50;i+ +) { x=i; if(%2==0) if(x%3==0) if(x%7==0) printf("%d",i); } } 输出结果是 ()
A.28
B.27
C.42
D.41
第11题
阅读下面的程序,该程序().
main()
{ int a=5,b=0,c=0;
if(a=b+c) printf("***/n");
else printf("$$$/n"); }
A、可以通过编译但不能通过连接
B、输出***
C、输出$$$
D、有语法错不能通过编译