using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace 第六天_for循环的嵌套
{
class Program
{
static void Main(string[] args)
{
int num01;
int num02;
for (num01 = ; num01 <= ; num01++)
{
for (num02=; num02 <= num01; num02++)
{ Console.Write("{0}*{1}={2}\t", num01, num02, num01 * num02);
if (num01 <= num02)
{
Console.Write("\n");
}
} }
Console.ReadKey();
}
}
}

当某个事情要做一边,另外一个事情要做N遍的时候,需要用到for循环的嵌套。

优化为:

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace 第六天_for循环的嵌套
{
class Program
{
static void Main(string[] args)
{
int num01;
int num02;
for (num01 = ; num01 <= ; num01++)
{
for (num02=; num02 <= num01; num02++)
{
Console.Write("{0}*{1}={2}\t", num01, num02, num01 * num02);
}
Console.WriteLine(); //Console.Write("\n");
}
Console.ReadKey();
}
}
}

引申:

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace 第六天_for循环的嵌套
{
class Program
{
static void Main(string[] args)
{
int num01;
int num02;
for (num01 = ; num01 <= ; num01++)
{
for (num02=; num02 <= num01; num02++)
{ Console.Write("{0}*{1}={2}\t", num01, num02, num01 * num02); if (num01 <= num02)
{
Console.Write("\n");
break; //此处的break不起作用,在上面的for循环中起作用?为什么?
} } }
Console.ReadKey();
}
}
}

附带:

加法表

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace 第六天_do_while循环
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入一个数字:");
int num00=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("您得到的加法表为:");
for (int i = ; i<= num00; i++)
{ Console.WriteLine("{0}+{1}={2}", i, num00-i, num00); }
Console.ReadKey(); }
}
}

.Net基础篇_学习笔记_第六天_for循环的嵌套_乘法口诀表的更多相关文章

  1. 【笔记目录2】【jessetalk 】ASP.NET Core快速入门_学习笔记汇总

    当前标签: ASP.NET Core快速入门 共2页: 上一页 1 2  任务27:Middleware管道介绍 GASA 2019-02-12 20:07 阅读:15 评论:0 任务26:dotne ...

  2. 基础篇|一文搞懂RNN(循环神经网络)

    基础篇|一文搞懂RNN(循环神经网络) https://mp.weixin.qq.com/s/va1gmavl2ZESgnM7biORQg 神经网络基础 神经网络可以当做是能够拟合任意函数的黑盒子,只 ...

  3. C语言基础练习——打印乘法口诀表

    C语言基础练习--打印乘法口诀表 JERRY_Z. ~ 2020 / 8 / 26 转载请注明出处! 代码: /* * @Author: JERRY_Z. * @Date: 2020-08-26 16 ...

  4. .Net基础篇_学习笔记_第六天_for循环语法_正序输出和倒序输出

    for TAB  和 forr TAB using System; using System.Collections.Generic; using System.Linq; using System. ...

  5. .Net基础篇_学习笔记_第六天_For循环语法

    For循环:专门处理已知循环次数的循环.  小技巧:连续敲击两下TAB键循环体自动搭建完成. For循环语法: for(表达式1;表达式2;表达式3){ 循环体;}表达式1一般为声明循环变量,记录循环 ...

  6. .Net基础篇_学习笔记_第六天_异常捕获复习及断点调试

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

  7. Net基础篇_学习笔记_第九天_数组_冒泡排序(面试常见题目)

    冒泡排序: 将一个数组中的元素按照从大到小或从小到大的顺序进行排列. for循环的嵌套---专项课题 int[] nums={9,8,7,6,5,4,3,2,1,0}; 0 1 2 3 4 5 6 7 ...

  8. .Net基础篇_学习笔记_第五天_流程控制do-while循环

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

  9. 从实例学习 Go 语言、"基础与进阶" 学习笔记及心得体会、Go指南

    第一轮学习 golang "基础与进阶"学习笔记,Go指南练习题目解析.使用学习资料 <Go-zh/tour tour>.记录我认为会比较容易忘记的知识点,进行补充,整 ...

随机推荐

  1. 浅谈osi模型 三次握手 四次挥手 ddos攻击原理

    C/S B/S 架构 C:client 端 B:browser 浏览器 S:server 端 C/S架构,基于客户端与服务端之间的通信 例如:QQ,抖音,快手,微信,支付宝等等 优点:个性化设置,响应 ...

  2. 解决树莓派烧录系统后没有boot文件,只出现盘符问题

    首先,如果下图情况,说明你没有烧录好,继续向下看 放一张安装成功的图片 出现这个的原因是因为前期没有烧录好,它会回滚到img文件中,如果中途退出,它会写入到img文件中 正确文件大小(Raspbian ...

  3. 笑谈CSS的伪元素

    今晚上我们来简单的聊一聊CSS的伪元素,多说无益,开聊 GG: 话说盘古开天辟地之时. QQ:嗨,咱今天还能讲的完吗?您给来点实际的啊. GG:要听实际的是吧,得嘞,那今天咱就来聊一聊CSS里的伪元素 ...

  4. 建立apk定时自动打包系统第二篇——自动上传文件

    在<建立apk定时自动打包系统第一篇——Ant多渠道打包并指定打包目录和打包日期>这篇文章中介绍多渠道打包的流程.很多时候我们需要将打包好的apk上传到ftp中,这时候我可以修改custo ...

  5. Hive 系列(六)—— Hive 视图和索引

    一.视图 1.1 简介 Hive 中的视图和 RDBMS 中视图的概念一致,都是一组数据的逻辑表示,本质上就是一条 SELECT 语句的结果集.视图是纯粹的逻辑对象,没有关联的存储 (Hive 3.0 ...

  6. ts 学习笔记 - 泛型

    目录 泛型 举个栗子 泛型约束 多个参数时也可以在泛型约束中使用类型参数 泛型接口 泛型类 泛型参数的默认类型 泛型 泛型(Generics)是指在定义函数.接口或者类的时候, 不预先指定其类型,而是 ...

  7. PythonI/O进阶学习笔记_3.1面向对象编程_python的多态和鸭子类型

    前言: 与第一篇的面向对象内容不同的是,第一篇中的面向对象更多的是与类.对象结合起来的概念粗浅理解,就是在编程历史中诞生的一种思想方法. 这篇的面向对象编程,更多落实到在语言设计实现中,是如何体现面向 ...

  8. Leetcode之深度优先搜索(DFS)专题-1080. 根到叶路径上的不足节点(Insufficient Nodes in Root to Leaf Paths)

    Leetcode之深度优先搜索(DFS)专题-1080. 根到叶路径上的不足节点(Insufficient Nodes in Root to Leaf Paths) 这篇是DFS专题的第一篇,所以我会 ...

  9. Elasticsearch核心技术(2)--- 基本概念(Index、Type、Document、集群、节点、分片及副本、倒排索引)

    Elasticsearch核心技术(2)--- 基本概念 这篇博客讲到基本概念包括: Index.Type.Document.集群,节点,分片及副本,倒排索引. 一.Index.Type.Docume ...

  10. ccpc网赛 hdu6703 array(权值线段树

    http://acm.hdu.edu.cn/showproblem.php?pid=6703 大意:给一个n个元素的数组,其中所有元素都是不重复的[1,n]. 两种操作: 将pos位置元素+1e7 查 ...