问题描述
这是我在下面编写的代码,但我可以弄清楚在我的代码运行时第21行的
赋值语句会执行多少次?
13 void f1(int a []){
14 int x,y;
15 int t;
16 for(x = 1; x< 10; x ++){
17 if(a [x] = a [x - 1]){
18 t = a [x];
19 y = x;
20 do {
21 a [y] = a [y - 1];
22 y-- ;
23} while(y 0&& a [y - 1] t);
24 a [y] = t;
25}
26}
27返回;
28}
29 int main(int argc, char ** argv)
30 {
31 int a [10];
32 char回复;
33 for(int i = 0; i< 10; i ++)a [i] = 100 - i;
34 f1(a);
35 for(int i = 0; i< 10; i ++)cout << i<< " ;. " << a [i]<< endl;
here is my code written below but i could figure out howmany times the
assignment statement at Line 21 execute when my code run?
13 void f1(int a[]) {
14 int x, y;
15 int t;
16 for(x = 1; x < 10; x++) {
17 if(a[x] = a[x - 1]) {
18 t = a[x];
19 y = x;
20 do {
21 a[y] = a[y - 1];
22 y--;
23 } while (y 0 && a[y - 1] t);
24 a[y] = t;
25 }
26 }
27 return;
28 }
29 int main (int argc, char **argv)
30 {
31 int a[10];
32 char reply;
33 for (int i = 0; i < 10; i++) a[i] = 100 - i;
34 f1(a);
35 for (int i = 0; i < 10; i++) cout << i << ". " << a[i] << endl;
推荐答案
添加一个计数器。
Add a counter.
-
Ian Collins。
--
Ian Collins.
添加一个计数器。
Add a counter.
-
Ian Collins.-隐藏引用的文字 -
- 显示引用的文字 -
--
Ian Collins.- Hide quoted text -
- Show quoted text -
i不明白Ian Collins是什么意思?请它是
紧急我需要打电话给这个作业然后把它打开......帮我!!!!
i didnt understand what does that mean Ian Collins? please it is
urgent i need to ork on this assignment and turn it in... help me!!!!
添加一个柜台。
Add a counter.
*请*不要引用签名。
*Please* don''t quote signatures.
一个变量计算生产线的执行次数。
不要把作业留到最后一刻!
-
Ian Collins。
A variable to count the number of times the line is executed.
Don''t leave your homework to the last moment!
--
Ian Collins.
这篇关于我的代码问题.....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!