免费预览已结束,剩余8页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 开发一个控制台应用程序,使之输出字符串“北京欢迎你!”。using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace test01 class Program static void Main(string args) Console.WriteLine(北京欢迎你!); 1、开发一个控制台应用程序,根据提示从键盘输入圆的半径,随后输出圆的面积和周长。using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace test02 class Program static void Main(string args) Console.WriteLine(请输入圆的半径); string str = Console.ReadLine(); double r = Double.Parse(str); double s = Math.PI * r * r; Console.WriteLine(圆的面积是0:f2, s); 1、 开发一个控制台应用程序,根据提示从键盘获取一个摄氏温度,请转换并输出对应的华氏温度。using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace test03 class Program static void Main(string args) Console.WriteLine(请输入摄氏温度:); float s = float.Parse(Console.ReadLine (); float c = 9 * s / 5 + 32; Console.WriteLine(输入摄氏温度0转换成的华氏温度1:f2,s,c); 1、开发一个控制台应用程序,根据提示从键盘输入一个字符,判断此字符是数字、大写字母、小写字母还是其它字符。using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace test04 class Program static void Main(string args) Console.WriteLine(请输入要判断字符); int c = Console.Read(); if (c = 0 & c = A & c = a & c = z) Console.WriteLine(该字符为小写字母); else Console.WriteLine(该字符为其他字符); 1、编写一个C#控制台应用程序,从键盘输入年份,判断此年份是不是闰年。using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace test05 class Program static void Main(string args) Console.WriteLine(请输入要判断的年份); int year = int.Parse(Console.ReadLine(); if (year % 4 = 0 & year % 100 != 0) | year % 400 = 0) Console.WriteLine(0年为闰年, year); else Console.WriteLine(0年为平年, year); 2、设计一个控制台应用程序,输入任意字符串,统计其中元音字母( a,e,i,o,u,不区分大小写)出现的次数及频率。using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace test01 class Program static void Main(string args) int countA = 0, countE = 0, countI = 0, countO = 0, countU = 0; Console.WriteLine(请输入字符串); String s = Console.ReadLine(); s = s.ToUpper(); char c = s.ToCharArray(); foreach (char ch in c) switch (ch) case A: countA+; break; case E: countE+; break; case I: countI+; break; case O: countO+; break; case U: countU+; break; default: break; Console.WriteLine(A出现频数为0,频率为1:P2, countA, countA * 0.1 / s.Length); Console.WriteLine(E出现频数为0,频率为1:P2, countE, countE * 0.1 / s.Length); Console.WriteLine(I出现频数为0,频率为1:P2, countI, countI * 0.1 / s.Length); Console.WriteLine(O出现频数为0,频率为1:P2, countO, countO * 0.1 / s.Length); Console.WriteLine(U出现频数为0,频率为1:P2, countU, countU * 0.1 / s.Length); 2、设计一个控制台应用程序,定义一个拥有3行4列的矩形数组,数组元素值随机生成,取值范围是1,50,在控制台打印出此数组元素。using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace test02 class Program static void Main(string args) int, a = new int3,4; Random r=new Random (); for(int i=0;i3;i+ ) for (int j = 0;j4;j+) ai, j = r.Next(1, 51); Console.Write(0,5, ai, j); Console .WriteLine (); 2、设计一个控制台应用程序,定义一个拥有3个元素的二维交错整型数组。三个元素长度分别是5、4、3,元素值随机生成,取值范围50,100。在控制台打印出此数组元素。using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace test03 class Program static void Main(string args) int a=new int 3; a0=new int5; a1=new int4; a2=new int3; Random r =new Random(); for(int i=0;ia.GetLength (0);i+) for (int j=0; j 0.000001) sum = sum + 1.0 / i; Console.Write(+1/0 , i); i+; Console.WriteLine(=0:f3,sum); 2、编写一个控制台应用程序,从键盘输入两个正整数m,n,求出两数字的最大公约数和最小公倍数。using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace test05 class Program static void Main(string args) Console.WriteLine(请输入第一个正整数); int m = int.Parse(Console.ReadLine(); Console.WriteLine(请输入第二个正整数); int n = int.Parse(Console.ReadLine(); int m1 = m; int n1 = n; while (n !=0) int k = m % n; m = n; n = k; Console .WriteLine (0和1的最大公约数=2,最小公倍数=3,m1,n1,m,m1*n1/m); 3、 开发一个窗体应用程序,放置一个文本框和一个命令按钮,通过单击按钮可以在文本框内显示“welcome to china!”4、 using System;5、 using System.Collections.Generic;6、 using System.ComponentModel;7、 using System.Data;8、 using System.Drawing;9、 using System.Linq;10、 using System.Text;11、 using System.Windows.Forms;12、 namespace test0113、 14、 public partial class Form1 : Form15、 16、 public Form1()17、 18、 InitializeComponent();19、 20、 private void button1_Click(object sender, EventArgs e)21、 22、 textBox1.Text =welcome to china!;23、 24、 25、 3、开发一个窗体应用程序,可以根据圆的半径计算圆的面积和周长。using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace test02 public partial class Form1 : Form public Form1() InitializeComponent(); private void button1_Click(object sender, EventArgs e) double r = double.Parse (this.textBox1.Text); this.textBox2.Text = (Math.PI * r * r).ToString(f3) ; this.textBox3.Text = (Math.PI * 2 * r).ToString(f3) ; 3、开发一个窗体应用程序,窗体上能接收华氏温度或者摄氏温度,点击相应按钮可以相互转换,要求转换后的华氏温度或者摄氏温度保留小数点后3位。using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace test03 public partial class Form1 : Form public Form1() InitializeComponent(); private void button1_Click(object sender, EventArgs e) double f= double.Parse (this.textBox1.Text.Trim (); double c = (f - 32) * 5 / 9; this.textBox2.Text = c.ToString(f3); private void button2_Click(object sender, EventArgs e) double c = double.Parse(this.textBox2.Text.Trim(); double f = c * 9 / 5 + 32; this.textBox1.Text = f.ToString(f3); 3、设计一个窗体应用程序,输入一个字符,判定此字符是数字、大写字母、小写字母,还是其它字符。要求:(1)使用类和对象组织算法(2)类中定义公有方法(判断字符归属)(3)在按钮单击事件中使用此类创建实例化对象,并调用对象的方法及返回值完成判断。using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace test04 public partial class Form1 : Form public Form1() InitializeComponent(); private void button1_Click(object sender, EventArgs e) char ch = char.Parse(textBox1.Text); Cjudge c = new Cjudge(); this.textBox2.Text = c.judge(ch); private void button2_Click(object sender, EventArgs e) this.textBox1.Text = ; this.textBox2.Text = ; public class Cjudge public string judge(char c) string s; if (c = a & c = A & c = 0 & c = 9) s = 数字; else s = 其他字符; return s; 4、开发一个窗体应用程序,可以根据圆的半径计算圆的面积和周长。具体要求如下:(1)设计一个方法求圆的面积。(2)求圆面积的方法要定义重载方法,既能接收字符串参数,也能接收单精度类型参数。(3)设计一个方法求圆的周长。(4)求圆周长的方法要定义重载方法,既能接收字符串参数,也能接收单精度类型参数。using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace tes
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
评论
0/150
提交评论