如何用C#输出一个直角三角形
namespace直角三角形{classProgram{staticvoidMain(string[]args){stringStar="*";/*defineastri...
namespace 直角三角形
{
class Program
{
static void Main(string[] args)
{
string Star = "*";
/*define a string to output "*"*/
int i, k, j,l;
/*define some integers to use as loop variable*/
Console.WriteLine("please input a number");
/*intput the target number to contron the output "*"*/
i = Convert.ToInt32(Console.ReadLine());
/*give a target number*/
for (j = 1; j <= i; j += 2) ;
/*loop and let the loop number less than the target number,to control the number of line*/
{
for (k = 0; k <= j; k++) ;
/*loop and control the number of stars of each line*/
{ Console.WriteLine(Star); }
}
/*print the stars */
Console.ReadKey();
/*quit the program*/
主要是我每次都找不到问题好焦虑TT求高手解答~~~渣渣一枚飘过~~ 展开
{
class Program
{
static void Main(string[] args)
{
string Star = "*";
/*define a string to output "*"*/
int i, k, j,l;
/*define some integers to use as loop variable*/
Console.WriteLine("please input a number");
/*intput the target number to contron the output "*"*/
i = Convert.ToInt32(Console.ReadLine());
/*give a target number*/
for (j = 1; j <= i; j += 2) ;
/*loop and let the loop number less than the target number,to control the number of line*/
{
for (k = 0; k <= j; k++) ;
/*loop and control the number of stars of each line*/
{ Console.WriteLine(Star); }
}
/*print the stars */
Console.ReadKey();
/*quit the program*/
主要是我每次都找不到问题好焦虑TT求高手解答~~~渣渣一枚飘过~~ 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |