using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace 作业题1
{
class Program
{
static void Main(string[] args)
{
//打行数
for (int i = ; i < ; i++)
//打列数
{
for (int j = ; j <= i; j++)
{
Console.Write("★");
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}

输出结果:

第二题

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace 作业题2
{
class Program
{
static void Main(string[] args)
{
//打行数
for (int i = ; i < ; i++)
//打列数
{
for (int j = ; j>i; j--)
{
Console.Write("★");
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}

输出结果:

第三题

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace 作业题3
{
class Program
{
static void Main(string[] args)
{
//打行数
for (int i = ; i < ; i++)
//打列数
{
for (int j = ; j > i+; j--)
{
Console.Write(" ");
} for (int t = ; t <= i; t++)
{
Console.Write("★");
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}

输出结果:

第四题

sing System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace 作业题4
{
class Program
{
static void Main(string[] args)
{
//打行数
for (int i = ; i < ; i++)
//打列数
{
for (int j = ; j <= i-; j++)
{
Console.Write(" ");
} for (int t = ; t >i;t-- )
{
Console.Write("★");
}
Console.WriteLine();
}
Console.ReadLine(); } }
}

输出结果:

第五题

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace 作业题5
{
class Program
{
static void Main(string[] args)
{
//打行数
for (int i = ; i < ; i++)
//打列数
{
for (int j = ; j > i ; j--)
{
Console.Write(" ");
} for (int t = ; t <=i; t++)
{
Console.Write("★");
}
for (int p = ; p <= i-; p++)
{
Console.Write("★");
} Console.WriteLine();
}
Console.ReadLine();
}
}
}

输出结果:

第六题

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace 作业题6
{
class Program
{
static void Main(string[] args)
{
//打行数
for (int i = ; i <= ; i++)
{
for (int j =; j<i; j++)
{
Console.Write(" ");
} for (int t = ; t >i; t--)
{
Console.Write("★");
}
for (int m=; m>i-;m-- )
{
Console.Write("★");
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}

输出结果:

打菱形

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace 作业总
{
class Program
{
static void Main(string[] args)
{
//打行数
for (int i = ; i < ; i++)
//打列数
{
for (int j = ; j > i; j--)
{
Console.Write(" ");
} for (int t = ; t <= i; t++)
{
Console.Write("★");
}
for (int p = ; p <= i - ; p++)
{
Console.Write("★");
} Console.WriteLine();
}
//打行数
for (int n = ; n <=; n++)
{
for (int j = ; j <n; j++)
{
Console.Write(" ");
} for (int t = ; t > n; t--)
{
Console.Write("★");
}
for (int m = ; m > n - ; m--)
{
Console.Write("★");
}
Console.WriteLine();
}
Console.ReadLine(); }
}
}

输出结果:

如果输入奇数,打印菱形,最多的一行★的数量等于你输入的这个数。

输入偶数,提示错误。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace boss级作业
{
class Program
{
static void Main(string[] args)
{
Console.Write("请输入一个奇数:");
int num = Convert.ToInt32(Console.ReadLine()); if (num % == )
{
//打行数
#region
for (int i = ; i <= (num + ) / ; i++)
//打列数
{
for (int j = ; j <= num - (num - ) / - i - ; j++)
{
Console.Write(" ");
} for (int r = ; r < * i - ; r++) { Console.Write("★"); } Console.WriteLine();
} #endregion # region
for(int i=;i<(num-)/;i++)
{
for(int j=;j<=i;j++)
{
Console.Write(" ");
}
for(int t=;t<(num-)-i*;t++)
{
Console.Write("★");
}
Console.WriteLine();
}
#endregion
} else
{
Console.WriteLine("您输入的数字是错误的!");
} Console.ReadLine();
}
}
}

输出结果:

c#基础——for循环嵌套经典练习题(打★)的更多相关文章

  1. JS循环+循环嵌套+经典例题+图形题

    首先,了解一下循环嵌套的特点:外层循环转一次,内层循环转一圈. 在上一篇随笔中详细介绍了JS中的分支结构和循环结构,我们来简单的回顾一下For循环结构: 1.for循环有三个表达式,分别为: ①定义循 ...

  2. Java基础_循环嵌套_打印乘法口诀、菱形,各种图形,计算二元一次和三元一次方程组_7

    循环嵌套 打印乘法口诀 for(int j=1;j<=9;j++){ for(int i=1;i<=j;i++){ System.out.print(i+"*"+j+& ...

  3. JAVA_SE基础——15.循环嵌套

    嵌套循环是指在一个循环语句的循环体中再定义一个循环语句结构,while,do-while,for循环语句都可以进行嵌套,并且可以互相嵌套,下面来看下for循环中嵌套for循环的例子. 如下: publ ...

  4. 6、C#基础整理(for 语句经典习题--for循环嵌套、穷举)

    1.for循环嵌套----最基础题目:求阶乘的和 ; int n = int.Parse(Console.ReadLine()); ; i < n; i++) { ;//定义变量sum1,每次循 ...

  5. 【视频+图文】Java基础经典练习题(一)输出2-100之间的素数,及素数个数

    目录 第一题:判断2-100之间有多少个素数,并输出所有素数. 1.视频讲解: 2.思路分析: 代码讲解:以i=4为例 4.为大家准备了彩蛋: 能解决题目的代码并不是一次就可以写好的 我们需要根据我们 ...

  6. 2017-2-24 C#基础 for循环的嵌套

    用几个练习题演示一下for循环的嵌套 1.打印以下图形 ★★★★★★★★★★★★★★★ namespace _2017_2_24_for循环的嵌套 { class Program { static v ...

  7. 【JS中循环嵌套常见的六大经典例题+六大图形题,你知道哪几个?】

    首先,了解一下循环嵌套的特点:外层循环转一次,内层循环转一圈. 在上一篇随笔中详细介绍了JS中的分支结构和循环结构,我们来简单的回顾一下For循环结构: 1.for循环有三个表达式,分别为: ①定义循 ...

  8. java基础:进制详细介绍,进制快速转换,二维数组详解,循环嵌套应用,杨辉三角实现正倒直角正倒等腰三角,附练习案列

    1.Debug模式 1.1 什么是Debug模式 是供程序员使用的程序调试工具,它可以用于查看程序的执行流程,也可以用于追踪程序执行过程来调试程序. 1.2 Debug介绍与操作流程 如何加断点 选择 ...

  9. 黑马程序员——JAVA基础之程序控制流结构之循环结构,循环嵌套

    ------- android培训.java培训.期待与您交流! ---------- 循环结构: 代表语句:while ,do while ,for while语句格式 : while(条件表达式) ...

随机推荐

  1. Android开发:View的几种布局及实践

    引言 View的布局显示方式有下面几种:线性布局(Linear Layout).相对布局(Relative Layout).表格布局(Table Layout).网格视图(Grid View).标签布 ...

  2. Zepto.js-事件处理

    http://www.webdevs.cn/article/68.html     web开发网 事件 $.Event $.Event(type, [properties]) ⇒ event 创建并初 ...

  3. 在delphi中,DLL加载时做初始化的Demo

    library DLLEntry;//dll源码 uses SysUtils, Classes, Dialogs, Windows; {$R *.res} procedure DLLEntryPoin ...

  4. --@angularJS--一个简单的UI-Router路由demo

    1.index.html: <!DOCTYPE HTML><html ng-app="routerApp"><head>    <titl ...

  5. Activity的生命周期与加载模式——Activity的4种加载模式

    配置Activity时可指定android:launchMode属性,该属性用于配置该Activity的加载模式,该属性支持如下4个属性值. standard:标准模式,这是默认的加载模式. sing ...

  6. HTML 颜色值

    HTML 颜色值 颜色由红(R).绿(G).蓝(B)组成. 颜色值 颜色值由十六进制来表示红.绿.蓝(RGB). 每个颜色的最低值为0(十六进制为00),最高值为255(十六进制为FF). 十六进制值 ...

  7. 看完让你彻底搞懂Websocket原理

    偶然在知乎上看到一篇回帖,瞬间觉得之前看的那么多资料都不及这一篇回帖让我对 websocket 的认识深刻有木有.所以转到我博客里,分享一下.比较喜欢看这种博客,读起来很轻松,不枯燥,没有布道师的阵仗 ...

  8. doubango简介

    1.doubango官网:http://www.doubango.org/ doubango常用项目国内镜像(放在淘宝的svn服务器),目前有4个项目:doubango, idoubs, imsdro ...

  9. 蓝桥网试题 java 基础练习 回文数

    --------------------------------------------------------------------- 没必要枚举出所有四位数 四位数里是回文的数都有一个特性,是什 ...

  10. 详谈Struts2

    介绍struts2: struts2是一个基于mvc设计模式的web层框架. 详谈struts2的执行流程: struts2的执行流程:用户发送请求---->首先经过Struts2的核心过滤器- ...