如何使用循环语句缩短程序
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/21 18:50:09
如何使用循环语句缩短程序
subplot(521);
plot(index,a1);
subplot(522);
plot(index,a2);
subplot(523);
plot(index,a3);
subplot(524);
plot(index,a4);
subplot(525);
plot(index,a5);
subplot(526);
plot(index,d1);
subplot(527);
plot(index,d2);
subplot(528);
plot(index,d3);
subplot(529);
plot(index,d4);
subplot(5,2,10);
plot(index,d5); 以上是程序的一部分,我想问下可不可以把这段程序用循环语句简练的表达出来,这样实在是太麻烦了,麻烦大神老师们给看看,跪谢!
subplot(521);
plot(index,a1);
subplot(522);
plot(index,a2);
subplot(523);
plot(index,a3);
subplot(524);
plot(index,a4);
subplot(525);
plot(index,a5);
subplot(526);
plot(index,d1);
subplot(527);
plot(index,d2);
subplot(528);
plot(index,d3);
subplot(529);
plot(index,d4);
subplot(5,2,10);
plot(index,d5); 以上是程序的一部分,我想问下可不可以把这段程序用循环语句简练的表达出来,这样实在是太麻烦了,麻烦大神老师们给看看,跪谢!
也许可以这样:
1、subplot语句因为其参数是有规律地递增,所以是完全可以用循环表达的.
2、plot语句,其中的index和第二个参数是常量还是变量?如果index是变量,则可以在每次循环中进行更新.第二个参数,完全可以把a1, a2, a3, a4,a5, d1,等等,这样的参数事先组成一个数组,然后每次循环读取对应的值,然后数组的索引递增,这样就能把两个语句都放到循环中了.
1、subplot语句因为其参数是有规律地递增,所以是完全可以用循环表达的.
2、plot语句,其中的index和第二个参数是常量还是变量?如果index是变量,则可以在每次循环中进行更新.第二个参数,完全可以把a1, a2, a3, a4,a5, d1,等等,这样的参数事先组成一个数组,然后每次循环读取对应的值,然后数组的索引递增,这样就能把两个语句都放到循环中了.
如何使用循环语句缩短程序
VB程序中关于循环语句:“FOR”的使用
循环语句中如何快速判断是使用>或是>=?
编写c程序,使用循环语句,计算1到100的所有奇数之和.
请使用双重循环语句编写程序,打印出如下所示图形
使用while 和do-while 和for 循环语句编写程序
1、(用C语言编写程序)输入n值,输出如图所示平行四边形.(使用循环语句)
编写程序,使用循环语句来计算0到100的所有奇数之和
编写程序使用循环语句求1!+2!+3!+…+10!
如何设计matlab程序,两个for循环,其中一个for循环中包括一个if语句,程序中出现错误,如何修改
(1)编写程序输出如下面所示的九九乘法表,禁止直接使用输出语句原样输出,一定要使用循环语句.\x05
使用do..while循环和switch语句制作一个选课程序,根据客户选择输出所选的课程.