下面程序的运行结果是( )。 #include<iostream.h> int fun(int a[],int n) int result=1; for(int i=1;i<n;i++) result=result *a[i]; return result; void main() int a[3]=3,4,5; eout<<fun(a,3)<<end1;[/i]
A: 12
B: 15
C: 20
D: 60
A: 12
B: 15
C: 20
D: 60
举一反三
- 以下程序的运行结果为:int fun(int n){ if(n==1) return 1; else return fun(n-1)+1;} int main(){ int i,j=0; for(i=1;i<3;i++) j += fun(i); printf("%d\n",j); return 0;}
- 下面程序段的输出结果是( )。 public class Test public static void main (String[] args) int n=10,result=0; for (int i=1;i<=n;i++) result+=i; System.out.println("result is"+result); A: A) result is 55 B: B) result is 45 C: C) result is 56 D: D) result is 54
- 下面程序段的输出结果是( )。 public class Test public static void main ( String[] args) int result=0; for ( int i=1;i<=5;i++) if ( i%2==0 ) continue; result + =i; System. out. println ("result is " + result ); A: result is 7 B: result is 8 C: result is 9 D: result is 10
- 下面程序的运行结果是______。#include "stdio.h"void exchange(int a[],int n){ int i; for(i=1;i<n;i+=2) a[i]=a[i]+a[i-1];}void main(){ int i,m[5]={1,2,3,4,5}; exchange(m,5); for(i=0;i<5;i++) printf("%d",m[i]);}[/i][/i][/i]
- 下列程序的输出结果是______。 #include<iostream.h> template<class T> T max(T x[],int n) int i; T max v=x[0]; for(i=1;i<n;i++) if(max v<x[i]) max v=x[i]; return max v; void main() int a[]=3,2,7,6,8,9; double b[]=(1.2,3.4,2.5,7.3,6.8; cout<<max(a,4)<<", "<<max(b,3)<<end1;[/i][/i]