如何使程序显示两个程序的结果排列horizo​​ntalky [英] How to make program that show the result of two program line up horizontalky

查看:67
本文介绍了如何使程序显示两个程序的结果排列horizo​​ntalky的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有两个不同的程序使用循环,我想制作程序同时显示两个程序结果排队,我们混淆的是它们都用于循环功能所以在调试它时,第一个程序将显示所有结果垂直然后继续第二个program.I尝试使用嵌套循环打印行作为外部循环,但两个程序的循环的迭代次数是不同的所以我不能统一它。



There are two different program that use loop, I want to make program that show both of two program result line up horizontally, what im confuse is both of them use for loop function so when debug it, the first program will show all the result vertically then continue to second program.I tried to use nested loop to print row as outside loop but the number of iteration for the loop of two program is different so i cant unify it.

first program :
  int main()
  {
   float x;
   int i;
      for(i=0;i<=100;i++) {
          x=i/100.0;
          printf("x=%f\n",x);
                     }
     return 0;
    }

  second program:
int main()
 {
   float x;
   for(x=0.0;x<=1.0;x+=0.01)
          {
             printf("x=%f\n",x);
            }
 return 0;
    }





我尝试过:



尝试使用嵌套循环来打印行,但外部循环条件也确定结果,而两个程序将增加1但具有不同的条件



What I have tried:

tried to use nested loop to print row but the outside loop condition also determine the result while the two program will increment by 1 but have different condition

for ( init; condition; increment ) {
   statement(s);
 }



或者可能使用数组(?)


Or maybe use array(?)

推荐答案

我建​​议你只用一个程序来产生结果。

你可以使用单个循环,或者更好(至少在我看来)将结果收集到数组中,并在计算结束时输出根据您的需要。
I suggest you to produce the results with just one program.
You may either use a single loop, or better (at least in my opinion) collect the results into arrays and, at the end of the computations, output them according to your needs.


这篇关于如何使程序显示两个程序的结果排列horizo​​ntalky的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆