已阅读5页,还剩6页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
武汉纺织大学.Net程序设计实验报告电子 专业 班 姓名: 实验时间:2015 年 5 月 8 日一、 实验目的:了解Visual S开发工具的主要功能掌握C#程序程序设计的基本过程掌握C#的语言基础和流程控制语法二、 实验内容:完成P19页3编程题完成P44页3编程题完成P70页4编程题完成P95页3编程题三、 操作步骤:P19页3编程题:相关代码:namespace exp1_1 public partial class Form1 : Form public Form1() InitializeComponent(); private void label1_Click(object sender, EventArgs e) label1.Text = 我的第一个Visual C# 2008 windows 应用程序!; private void button1_Click(object sender, EventArgs e) Application.Exit(); 程序运行截图:P44页3编程题(1)相关代码: private void textBox1_TextChanged(object sender, EventArgs e) if(textBox1.Text.Length 4) label4.Text = 最多只能输入个字符; textBox1.Text=; textBox1.Focus(); 截图:(2)相关代码:private void button1_Click(object sender, EventArgs e) this.Text = textBox1.Text; private void button2_Click(object sender, EventArgs e) this.Text = ; textBox1.Text=; 截图:P70页4编程题(1)相关代码:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1 class Program static void Main(string args) Console.Write(请?输?入?一?个?整?数y:); string a = Console.ReadLine(); int x = int.Parse(a); Console.WriteLine(输?出?的?整?数y;0,x); 程序运行截图:(2)相关代码:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1 class Program static void Main(string args) Console.WriteLine(请输入第一个数:); int x = int.Parse(Console.ReadLine(); Console.WriteLine(请输入第二个数:); int y = int.Parse(Console.ReadLine(); Console.WriteLine(两数之和:2, x, y, x + y); Console.WriteLine(两数之差:2, x, y, x - y); Console.WriteLine(两数之积:2, x, y, x * y); Console.WriteLine(两数之商:2, x, y, x / y); Console.WriteLine(两数取余:2,x, y, x %y); Console.ReadKey(); 程序运行截图:(3)相关代码:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1 class Program static void Main(string args) Console.WriteLine(请输入一个小写字母:); string x = Console.ReadLine(); string y = x.ToUpper(); Console.WriteLine(输出其大写字母为:0, y); Console.ReadKey(); 程序运行截图:P95页3编程题(1)相关代码:For循环:using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication1 class Program static void Main(string args) Console.WriteLine(for循环计数如下:); for (int n = 100; n =200; n+=2) Console.Write(n.ToString(); Console.Write( ); Console.ReadKey(); 程序运行截图:While循环;using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication1 class Program static void Main(string args) Console.WriteLine(while循环计数如下: ); int n = 100; while (n = b & b = c) max = a; middle = b; min = c; else if (a = c & c = b) max = a; middle = c; min = b; else if (b = a & a = c) max = b; middle = a; min = c; else if (b = c & c = a) max = b; middle = c; min = a; else if (c = a & a = b) max = c; middle = a; min = b; else if (c = b & b = a) max = c; middle = b; min = a; Console.Write(三个数中最小的数为:); Console.WriteLine(min.ToString(); Console.Write(三个数从小到大排列:); Console.Write(max.ToString(); Console.Write( ); Console.Write( middle.ToString(); Console.Write( ); Console.Write( min.ToString(); Console.ReadKey(); 程序运行截图:(3)相关代码:using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication1 class Program static void Main(string args) int score; Console.WriteLine(你考了多少分(0100)?); score = int.Parse(Console.ReadLine(); score = score / 10; switch (score) case 10: Console.WriteLine(成绩等级:优); break; case 9: Console.WriteLine(成绩等级:优); break; case 8: Console.WriteLine(成绩等级:良); break; case 7: Console.WriteLine(成绩等级:中); break; case 6: Console.WriteLine(成绩等级:中); break; default: Console.WriteLine(成绩等级:差); break; Console.ReadLine(); 程序运行截图:(4)相关代码:using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication1 class Program static void Main(string args) Console.WriteLine(输出15的平方值:); for (int i = 1; i = 5; i+) Console.WriteLine(i.ToString() + 的平方: + (i * i).ToString(); Console.ReadLine(); 程序运行截图:(5)相关代码:using System;using System.Collections.Generic;using System.Text;namespace ConsoleApplication1class Program const int row = 6; static void Main(string args) int, array = new introw, row; int i, j;/求杨辉三角值 for (i = 0; i row; i+) arrayi, 0 = 1; arrayi, i = 1; for (i = 2; i row; i+) for (j = 1; j i; j+) arrayi, j = arrayi - 1, j - 1 + arrayi - 1, j; /输入直角三角形 for (i = 0; i row; i+) for (j = 0;
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 防尘口罩介绍课件
- 妇产科常用穴位课件
- 9-10-Dihydrophenanthrene-生命科学试剂-MCE
- 6-Hydroxy-2-2-4-4-tetrabromodiphenyl-ether-生命科学试剂-MCE
- 防尘防爆课件
- 房产办公行政模板课件
- 2026-2027学年初中心理健康七年级下册北京版第二节 乐观的人永生不老课时练
- 2026-2031年中国社保基金行业市场调查研究及发展前景预测报告
- 建筑施工施工升降机安全教育培训
- 航空航天展厅展陈布置方案
- 2026年70周岁以上老年人三力测试题库及答案
- 2026年企业首席质量官培训考核试题及答案
- 2026中国丘陵山区农机技术突破与市场推广策略报告
- 神经外科重症患者脑脊液外引流管理专家共识(2026版)解读
- 2026年一级电工(高级工三级)职业技能等级认定考试题库(完整版含标准答案)
- 新生儿脐带结扎滑脱护理查房
- 电焊机安全操作规范培训
- 南汽汽轮机调速系统学习资料
- 高等教育学-潘懋元
- 认知障碍照护者技能培训方案
- 全国大学生职业规划大赛《机械设计制造及其自动化》专业生涯发展展示【曾获省级奖项】
评论
0/150
提交评论