1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <iostream> using namespace std; int i,j,k,a[101]; int main(){ for (int i = 0; i <=100; i++)a[i]=i; for (k=5; k>=2; --k){ for ( i =1 ; i <=100; i++)if(i%k==0)a[i]=0; for ( i =1; i <=99; i++) for (j = 1; j <= 100-i; j++) if(a[j]>a[j+1]) { a[j]=a[j]+a[j+1]; a[j+1]=a[j]-a[j+1]; a[j]=a[j]-a[j+1]; } } j=1; while (a[j]==0 && j<100)j=j+1; for ( i = j; i <=100; i++)a[0]=a[0]+a[i]; cout<<a[0]; } |
0 of 5 Questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
1、去掉第18行,输出结果不变。( )
2、第12~14行的代码是交换a[j]和a[j+1]的值( )。
3、将第09行的i=1改为i=101-k*20,程序输出结果不变。( )
4、第8行到15行的排序方式为。( )
5、程序输出结果为( )