学习软件设计——C#练习(1)
来源:互联网 发布:万能搬家软件好用吗 编辑:程序博客网 时间:2024/06/13 02:53
1.编写一个类,要求从控制台输入长方形的长和宽,计算面积和周长并且输出到控制台。
2.编写一个类,要求从控制台输入年份,计算输入的年份是否为闰年,闰年的判断是能被4整除并且不能被100整除,或者是能被400整除的年份
bool 是否为闰年 = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
3、编写一个类,要求从控制台输入3个数字,计算输入的3个数中最大的数,并且输出。
- using System;
- using System.Collections.Generic;
- public class MyClass
- {
- public static void Main()
- {
- Console.WriteLine("请输入长方形的长:");
- int a=int.Parse(Console.ReadLine());
- Console.WriteLine("请输入长方形的宽:");
- int b=int.Parse(Console.ReadLine());
- Console.WriteLine("长方形的面积为:{0}",a*b);
- Console.WriteLine("长方形的周长为:{0}",(a+b)*2);
- Console.ReadLine();
- }
- }
- using System;
- using System.Collections.Generic;
- public class MyClass
- {
- public static void Main()
- {
- Console.WriteLine("请输入日期:");
- int year=int.Parse(Console.ReadLine());
- if((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
- {
- Console.WriteLine("为闰年");
- }
- else
- {
- Console.WriteLine("不为闰年");
- }
- Console.ReadLine();
- }
- }
- using System;
- using System.Collections.Generic;
- public class MyClass
- {
- public static void Main()
- {
- Console.WriteLine("请输入第1个数字:");
- int a = int.Parse(Console.ReadLine());
- Console.WriteLine("请输入第2个数字:");
- int b = int.Parse(Console.ReadLine());
- Console.WriteLine("请输入第3个数字:");
- int c = int.Parse(Console.ReadLine());
- int temp = 0;
- if(a > b)
- {
- temp = a;
- a = b ;
- b = temp;
- }
- if(a > c)
- {
- temp = a;
- a = c;
- c = temp;
- }
- if (b > c)
- {
- temp = b;
- b = c;
- c = temp;
- }
- Console.WriteLine("最大的数: {0}",c);
- Console.ReadLine();
- }
- }
- 学习软件设计——C#练习(1)
- 学习软件设计——C#练习(1)
- 学习软件设计——C#练习(2)
- 学习软件设计——C#练习(3)
- 学习软件设计——C#练习(4)
- 学习软件设计——C#练习(5)
- 学习软件设计——C#练习(6)
- 学习软件设计——C#练习(7)
- 学习软件设计——C#练习(8)
- 学习软件设计——C#练习(9)
- 学习软件设计——C#练习(10)
- 学习软件设计——C#练习(11)
- 通过逆向学习软件设计(1)
- C#学习笔记之——一些练习
- C#学习笔记—二维数组的练习
- VB:绘图示例—屏保软件设计1
- 软件工程——软件设计
- 【软件工程】——软件设计
- jQuery技巧:保证你的代码安全
- android bitmap byte[] drawable互转
- 世界上最遥远的距离
- PB TreeView 属性,事件详解
- c++二维数组的应用
- 学习软件设计——C#练习(1)
- Android拍照Demo
- 重载自减运算符
- 全局变量和局部变量在内存里的区别
- Objective-C选择器 Selector
- 减少windows7内存占用的优化方案
- sencha-touch-1.1如何动态更新panel的title
- 使图片在不加链接的情况下,onMouseOver显示手形状
- AVR 单片机与GCC 编程之存储器操作(转载)