For loop 用于循环生成类似于查找类似三角形的对应部分的输出

For loop 用于循环生成类似于查找类似三角形的对应部分的输出,for-loop,increment,dev-c++,For Loop,Increment,Dev C++,请帮帮我。我试图在DEV C++中编写一个程序,它可以接受斜边值、长腿、短腿,并将其与增量相乘。有点像一个程序,它可以找到三角形中与第一个三角形相似的对应部分 example (output) enter hypotenuse: enter longer leg: enter shorter leg: enter limitation: example input(hypotenuse 5, longer leg 4, shorter leg 3, limitation 4) 有多种方法可以生

请帮帮我。我试图在DEV C++中编写一个程序,它可以接受斜边值、长腿、短腿,并将其与增量相乘。有点像一个程序,它可以找到三角形中与第一个三角形相似的对应部分

example (output) enter hypotenuse: enter longer leg: enter shorter leg: enter limitation: example input(hypotenuse 5, longer leg 4, shorter leg 3, limitation 4)
有多种方法可以生成直角三角形。根据您在问题中给出的结果(输出),可以通过将每边乘以整数值(k=1,2,3,4,5,…)生成下一个三角形。你可以找到更多的信息。也可能有帮助。
一个可能的解决方案可以是:

void display(const char* str, int value, int times)
{
  std::cout<<str;
  for(int i = 1; i<=times; i++)
  std::cout<<value*(i+1)<<'\t';
  std::cout<<std::endl;
}
int main()
{
   int hyp,longLen,shortLen;
   int num;
   //I assume the input is a right angled triangle.
   cout<<"Enter hypotenuse: ";
   cin>>hyp;
   cout<<"Enter longer length: ";
   cin>>longLen;
   cout<<"Enter shorter length: ";
   cin>>shortLen;
   cout<<"Number of triangles to be displayed: ";
   cin>>num;
   display("Hypotenuse",hyp,num);
   display("Longer len",longLen,num);
   display("Shorter len",shortLen,num);
   return 0;
 }
void显示(常量字符*str,int值,int次)
{
标准::cout
void display(const char* str, int value, int times)
{
  std::cout<<str;
  for(int i = 1; i<=times; i++)
  std::cout<<value*(i+1)<<'\t';
  std::cout<<std::endl;
}
int main()
{
   int hyp,longLen,shortLen;
   int num;
   //I assume the input is a right angled triangle.
   cout<<"Enter hypotenuse: ";
   cin>>hyp;
   cout<<"Enter longer length: ";
   cin>>longLen;
   cout<<"Enter shorter length: ";
   cin>>shortLen;
   cout<<"Number of triangles to be displayed: ";
   cin>>num;
   display("Hypotenuse",hyp,num);
   display("Longer len",longLen,num);
   display("Shorter len",shortLen,num);
   return 0;
 }