c#小练习ⅰ
来源:互联网 发布:国债利率 知乎 编辑:程序博客网 时间:2024/05/10 08:25
使用VisualStudio编写控制台应用程序
从命令行输入半径,求对应的圆的周长、面积
using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace ConsoleApplication1{ class Class1 { static void Main(string[] args) { Console.WriteLine("输入圆的半径:"); int a = int.Parse(Console.ReadLine()); Console.WriteLine("圆的周长为:" + 2 * a * 3.14); Console.WriteLine("圆的面积为:" + 3.14 * a * a); } }}
使用VisualStudio编写控制台应用程序
从命令行读入三角形的三条边,判断是否可以构成三角形,如果可以,求三角形的周长
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 三角形{ class Program { staticvoid Main(string[] args) { Console.WriteLine("输入三角形三边:"); int[] a = { 0, 0, 0 }; for (int i = 0; i < 3; i++) { a[i] = int.Parse(Console.ReadLine()); } if (a[0] + a[1] > a[2] && a[0] + a[2] > a[1] && a[1] +a[2] > a[0]) { Console.WriteLine("能够构成三角形"); } else { Console.WriteLine("构不成三角形!!"); return; } Console.WriteLine("三边为:"); for (int i = 0; i < 3; i++) { Console.WriteLine(a[i] + " "); } } }}
使用VisualStudio编写控制台应用程序
从命令行读入三个整数,求三个整数的最大值
using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace abc_compar{ class Program { static void Main(string[] args) { Console.WriteLine("输入三个数字:"); int a = int.Parse(Console.ReadLine()); int b = int.Parse(Console.ReadLine()); int c = int.Parse(Console.ReadLine()); int d = (a > b ? a : b); Console.WriteLine(c>d?c:d); } }}
使用VisualStudio编写控制台应用程序
有一函数,编写一个程序,从键盘输入一个x 值,程序输出y 的值
using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace fun____{ class Program { static void Main(string[] args) { Console.WriteLine("输入一个数:"); while (true) { int a = int.Parse(Console.ReadLine()); if (a > 0) { Console.WriteLine(-1 + 3 * a); } else if (a < 0) { Console.WriteLine(-1 + 2 * a); } else if (a == 0) { Console.WriteLine("-1"); } } } }}
使用VisualStudio编写控制台应用程序
输出1-100 中能被3 整除但不能被5 整除的数,并统计这样的数有多少个
using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace _1_100{ class Program { static void Main(string[] args) { int num = 0; for (int i = 0; i <= 100; i++) { if (i % 3 == 0 && i % 5 != 0) { num++; Console.Write(" " + i); } } Console.WriteLine(); Console.WriteLine("能被3整除不能被5整除的数字共有:" + num); } }}
0 0
- c#小练习ⅰ
- C#小练习
- C# List小练习
- C#小练习
- C#小练习ⅱ
- C#小练习ⅲ
- C#小练习ⅳ
- C#小练习ⅴ
- C#小练习
- C#小练习08
- c#字符处理小练习
- C#数组(小练习)
- C#小练习(规律求数)
- C#小练习(猜数字)
- C#小练习:SerialPort读写操作
- c#小程序练习-用户注册
- C# 入门小练习(持续更新)
- C#小练习笔记:生成个玫瑰线图案
- Vim 一键编译、连接、运行 C/C++ 单文件(Windows 与 Linux通用)
- tag_on_failure => [] # prevent default _grokparsefailure tag on real records
- 不用storyboard创建一个app
- 生成式对抗网络GAN研究进展(二)——原始GAN
- 【CodeVS3955】最长严格上升子序列(加强版)
- c#小练习ⅰ
- 不使用storyboard创建一个app
- use echo $x as apposed to echo ($x)
- 机器学习优化算法—L-BFGS
- HDU 5876 Sparse Graph(补图 最短路 BFS map)
- 使用openfire搭建IM聊天系统(一)
- 【ThinkPHP系列篇】ThinkPHP框架的介绍和搭建(一)
- MySQL用事件完成每日新建子分表并插入当日母表记录
- 91. Decode Ways