美文网首页
20181220作业

20181220作业

作者: 楚荷音 | 来源:发表于2018-12-19 17:57 被阅读0次


作业1

打印直角三角形

  1. 需求说明
    (1) . 从控制台输入直角三角形的高度(行数)
    (2) . 每行 * 的数目依次为1、3、5、7…


代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp48
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入直角三角形行数:");
int i = Convert.ToInt32(Console.ReadLine());

        string a = "*";
        Console.WriteLine("*");
        for (int j=1; j < i;j++)
        {
            a = a + "**";
            Console.WriteLine("{0}", a);
         } 

        Console.ReadKey();
    }
}

}


效果


image.png


作业2

打印倒直角三角形

  1. 需求
    从控制台输入直角三角形的高度(行数)
    每行*的数目从下至上依次为1、2、3、4…

    代码

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

namespace ConsoleApp49
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入直角三角形的行数:");
int i =0;
int n = 0;
for (i = Convert.ToInt32(Console.ReadLine()); i > 0; i--)
{
for (n = i; n> 0; n--)
{
Console.Write("*");
}
Console.Write("\n");
}
Console.ReadKey();
}
}
}


效果


image.png


作业3

打印等腰三角形

  1. 需求
    从控制台输入等腰三角形的高度
    每行*的数目依次为1、3、5、7…


代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp51
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入等腰三角形的行数:");
int i= Convert.ToInt32(Console.ReadLine());
try
{
for (int j = 1; j< i + 1; j++)
{
for (int n =i-j;n> 0; n--)
{
Console.Write(" ");
}
for (int a= 0; a < 2 * j- 1; a++)
{
Console.Write("*");
}
Console.WriteLine("");
}
}
catch
{
Console.WriteLine("输入有误,请重新输入!");
}
Console.ReadKey();
}
}
}


效果


image.png


作业4

利用二重循环实现九九乘法表

代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int i;
int j;
for (i = 1;i<= 9; i++)
{
for (j =1; j <i; j++)
{
Console.Write("{0}{1}={2} ",j,i,i * j);
}
Console.WriteLine("{0}
{1}={2} ",j,i,i * j);
} Console.ReadKey();
}
}
}


效果


image.png

相关文章

  • 20181220作业

    …作业1…打印直角三角形 需求说明(1) . 从控制台输入直角三角形的高度(行数)(2) . 每行 * 的...

  • Day14

    20181220-Day14作业: 告别“我的”小我的争对错夺权利模式,进入“我们的”共赢共存模式,开始打造让每个...

  • 12月20日

    20181220-Day14作业: 告别“我的”小我的争对错夺权利模式,进入“我们的”共赢共存模式,开始打造让每个...

  • 寻找自己的节奏【20181121-20181220】

    【20181220】 Life is a shipwreck, but we must not forget to...

  • 罗维 157-158 20181220

    … …… … … …… 罗维 157-158 20181220-1148

  • 20181220

    今天我的语文第七单元试卷发了下来,我这一次考得不好,回来爸爸和我一起分析了错题。以后我会认真学习,吸取这次的错题,...

  • 20181220

    今天老师通知开家长会,老师讲了很多今后复习中要遇到的问题和注意事项,我感觉老师说的特别对。很快就到了孩子人...

  • 20181220

    无锡镁钛铒金属制品-陆圆 【日精进打卡第130天】 【知~学习】 《六项精进》2遍 共236遍 《大学》0遍 共1...

  • 20181220

    减肥第四天,早起第三天 昨天偶然看到了 瓜叶菊的微笑 买给我的 哈哈哈,开心的一批。 科幻电影课上老师重复 哎呀,...

  • 20181220

    在日常工作中,我们要抑制“只要自己好就行”的利己心,在判断事情时,经常自问自答:自己做人是否正确,是否夹杂着和私心。

网友评论

      本文标题:20181220作业

      本文链接:https://www.haomeiwen.com/subject/sgtskqtx.html