for循环C#中的商 [英] quotient in a for loop C#
问题描述
您好。
这是一个功课,所以不要给我答案。
IM将执行一个程序,在分子和分母中从1 -100查看每个分子和分母,商数为= 5,然后分子和分母将在屏幕上输出。
int num1,num2;
for (num1 = 1 ; num1 < ; = 101 ; num1 ++)
{
for (num2 = 1 ; num2 < = 101 ; num2 ++)
{
if (num1 + num2 == 101 )
Console.WriteLine(num1 + / + num2);
}
}
Console.ReadLine();
}
}
}
这就是我所做的。只需要显示denominatorf的商数为1- 100.
我知道我需要输入一个新的int然后在if中计算= 5但我真的不知道该怎么做任何人都可以帮助我。
对不起英文不好
程序将循环通过1-100 100-1并且每次商数= 5时,两个数字和= 5将在屏幕上显示例如10/2并且在控制台屏幕上显示
我试图输入< pre lang =cs> if (num1 / num2 == 5 )
控制台。 WriteLine(num1 + / + num2);
只显示它的一面,它不会只显示2的正确答案,然后它会做它所做的事情
Hello.
This is a homework so don''t give me the answer.
IM going to do a program that look in to every numerator and denominator from 1 -100 in both numerator and denominatorf the quotient is = 5 then the numerator and denominatorf will be typed out on the screen.
int num1, num2;
for (num1 = 1; num1 <= 101; num1++)
{
for (num2 = 1; num2 <= 101; num2++)
{
if (num1 + num2 == 101)
Console.WriteLine(num1 + " / " + num2);
}
}
Console.ReadLine();
}
}
}
this is what i have done. Only geting to show denominatorf the quotient to 1- 100.
I know that i need to put in a new int and then count out the = 5 in the if but i dont really know how to do it can any one help me whit it.
Sorry for the bad english
the program going to loop through 1-100 100-1 and every time the quotient is = 5 the two number and = 5 going to show on the screen for example 10/2 and that is going on the console screen
i tryd to put inif (num1 / num2 == 5) Console.WriteLine(num1+"/"+num2);
put it show only one side of it and it dont showe the right answer only on the 2 first and then it do what it whant
这篇关于for循环C#中的商的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!