using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 任务2_3
{
class Program
{
static void Main(string[] args)
{
//为使用do,while 设置一个控制变量
int cont = 0;
do
{
//下面用for循环输出上五层的三角形
for (int i = 1; i <= 5; i++)
{
for (int j = 1; j <= 5 - i; j++)
{
Console.Write(" ");
}
for (int j = 1; j <= (2 * i - 1); j++)
{
Console.Write("A");
}
Console.WriteLine();
}
//用for循环输出下四层的三角
for (int i = 4; i >= 1; i--)
{
for (int j = 1; j <= 5 - i; j++)
{
Console.Write(" ");
}
for (int j = 1; j <= (2 * i - 1); j++)
{
Console.Write("A");
}
Console.WriteLine();
}
cont = 1;
} while (cont == 0);
cont = 0;
do
{
//下面用for循环输出上三层的三角形
for (int i = 1; i <= 3; i++)
{
for (int j = 1; j <= 3 - i; j++)
{
Console.Write(" ");
}
for (int j = 1; j <= (2 * i - 1); j++)
{
Console.Write("B");
}
Console.WriteLine();
}
//用for循环输出下两层三角
for (int i =2; i>=1; i--)
{
for (int j = 1; j <= 3 - i; j++)
{
Console.Write(" ");
}
for (int j = 1; j <= (2 * i - 1); j++)
{
Console.Write("B");
}
Console.WriteLine();
}
cont = 1;
} while (cont == 0);
//解决.exe文件执行后瞬间消失问题
Console.Read();
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
练习使用for、while、do while、foreach in等循环语句
共52个文件
exe:12个
cs:8个
pdb:8个
需积分: 32 24 下载量 143 浏览量
2014-10-29
13:34:59
上传
评论
收藏 81KB RAR 举报
温馨提示
输出字符三角形 输出背靠背字符三角形 输出字符菱形 输出交替字符倒三角形
资源推荐
资源详情
资源评论
收起资源包目录
2.rar (52个子文件)
任务2_4
任务2_4
任务2_4.csproj 2KB
bin
Debug
任务2_4.vshost.exe 14KB
任务2_4.vshost.exe.manifest 490B
任务2_4.pdb 14KB
任务2_4.exe 5KB
obj
Debug
任务2_4.pdb 14KB
任务2_4.exe 5KB
TempPE
任务2_4.csproj.FileListAbsolute.txt 297B
Properties
AssemblyInfo.cs 1KB
Program.cs 1KB
任务2_4.suo 11KB
源代码.txt 1022B
任务2_4.sln 917B
任务2
任务2
bin
Debug
任务2.pdb 14KB
任务2.vshost.exe.manifest 490B
任务2.vshost.exe 14KB
任务2.exe 5KB
obj
Debug
任务2.pdb 14KB
任务2.csproj.FileListAbsolute.txt 269B
任务2.exe 5KB
TempPE
Properties
AssemblyInfo.cs 1KB
Program.cs 1KB
任务2.csproj 2KB
任务2.sln 911B
任务2.suo 11KB
源代码.txt 1KB
任务2_2
任务2_2.sln 917B
任务2_2
bin
Debug
任务2_2.pdb 14KB
任务2_2.vshost.exe.manifest 490B
任务2_2.exe 6KB
任务2_2.vshost.exe 14KB
obj
Debug
任务2_2.csproj.FileListAbsolute.txt 297B
任务2_2.pdb 14KB
TempPE
任务2_2.exe 6KB
Properties
AssemblyInfo.cs 1KB
Program.cs 1KB
任务2_2.csproj 2KB
任务2_2.suo 10KB
源代码.txt 1KB
任务2_3
任务2_3.sln 917B
任务2_3.suo 10KB
任务2_3
bin
Debug
任务2_3.exe 5KB
任务2_3.pdb 14KB
任务2_3.vshost.exe 14KB
任务2_3.vshost.exe.manifest 490B
obj
Debug
任务2_3.exe 5KB
任务2_3.csproj.FileListAbsolute.txt 297B
任务2_3.pdb 14KB
TempPE
Properties
AssemblyInfo.cs 1KB
Program.cs 2KB
任务2_3.csproj 2KB
源代码.txt 2KB
共 52 条
- 1
资源评论
霍先生MrH
- 粉丝: 72
- 资源: 49
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功