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. iOS 之 OC开发实战

    iOS 开发之登陆 iOS 程序初始一个带导航栏的视图 iOS 添加导航栏两侧按钮 iOS UITabBar

  2. rsync 实验

    参考1:http://www.jb51.net/LINUXjishu/142722.html 参考2:http://sookk8.blog.51cto.com/455855/328076 主服务器IP ...

  3. fork() && fork() || fork()

    http://blog.csdn.net/hs794502825/article/details/10242091 #include <unistd.h> #include <std ...

  4. MYSQL外键的使用以及优缺点

    主键和索引是不可少的,不仅可以优化数据检索速度,开发人员还省不其它的工作, 矛盾焦点:数据库设计是否需要外键.这里有两个问题:一个是如何保证数据库数据的完整性和一致性:二是第一条对性能的影响. 正方观 ...

  5. --@ui-router--登录页通过路由跳转到内页的demo

    今天还是来说一下angular中的路由模块.我们实际项目中,各个页面的切换是经常会与Auth相关的.比如我网站的后台,是需要登录过的用户才能进去,那么我们用angularJS做前端路由的时候应该怎么完 ...

  6. 完美解决夏天电脑cpu发烫问题

    最近有朋友跟我反馈,说苹果电脑虽然好用,但是一直有一个问题困扰着他,就是电脑散热的问题.每到夏天的时候,电脑运转之后就会发烫,用的特别的不舒服. 相信用电脑的都会有这样的感受吧,更加相信你们都用过以下 ...

  7. MFC中在基于对话框的窗体中使用CFileDialog导致菜单栏变灰的解决方案

    CSDN的博客编辑器实在是难用……转战博客园 直接把CSDN发的搬过来了 ————————————————————————————我是分割线———————————————————————————— 第 ...

  8. Cookie的一些用法

    Cookie的一些用法: package com.stono.servlet.listenerorder; import java.io.IOException; import java.io.Pri ...

  9. 基于Ubuntu 14.04构建tomcat7镜像

    1.创建Dockerfile文件(如果在Windows下编辑文件,一定要将格式转化为Linux格式文件,否则将导致Linux下查看文件每行多一个^M) # Pull base image FROM u ...

  10. MyBatis 源码分析——动态代理

    MyBatis框架是如何去执行SQL语句?相信不只是你们,笔者也想要知道是如何进行的.相信有上一章的引导大家都知道SqlSession接口的作用.当然默认情况下还是使用DefaultSqlSessio ...