c#,关于for穷举例题
2016-01-26 15:25
246 查看
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 cishu = 0;
for (int x = 0; x <= 150;x++ )
{
for (int y = 0; y <= 75;y++ )
{
for (int z = 0; z <= 30;z++ )
{
if (x * 1 + y * 2 + z * 5 == 150)
{
cishu++;
Console.WriteLine("第"+cishu+"种买法,"+x+"个一分,"+y+"个两分,"+z+"个五分");
}
}
}
}
Console.WriteLine("一共有"+cishu+"买法");
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace for穷举
{
class Program
{
static void Main(string[] args)
{
int cishu = 0;
for (int x = 0; x <= 150;x++ )
{
for (int y = 0; y <= 75;y++ )
{
for (int z = 0; z <= 30;z++ )
{
if (x * 1 + y * 2 + z * 5 == 150)
{
cishu++;
Console.WriteLine("第"+cishu+"种买法,"+x+"个一分,"+y+"个两分,"+z+"个五分");
}
}
}
}
Console.WriteLine("一共有"+cishu+"买法");
}
}
}
相关文章推荐
- C#使用委托调用主线程上的控件
- C# 导出excel单个单元格内容超出当前范围解决方法
- 从0自学C#03--文件流保存数据为txt/excel格式
- C# 采用Basic Auth传递Post或者GET 数据
- C# Coding & Naming Conventions
- C# 枚举的使用
- C#中抽象类和接口的区别
- C#索引器
- VMware 虚拟机 Vix开发简介
- C# 空值判断
- 京东价格监控软件开发技术探讨一:C#实现获取京东商品信息(价格、库存)
- C#在button按钮上显示箭头
- c#调用存储过程输出参数
- Accord C4.5决策树算法(C# C4.5决策树算法)
- C# Best Practices - Handling Strings
- MVC项目发布,C#,.Net
- C#构造函数
- [转载]C#实现获取浏览器信息
- C#中数组、ArrayList和List三者的区别
- c#大圣之路笔记——TFS解决离职人员文件签出遗留签入问题