C程序设计实验报告.docx
《C程序设计实验报告.docx》由会员分享,可在线阅读,更多相关《C程序设计实验报告.docx(47页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、学 生 实 验 报 告理工类课程名称: 学生学号: 所属院部:C#程序设计专业班级: M11计算机科学与技术专转本 XXXXXXXX 学生姓名:XXX信息技术学院 指导教师:XXX2023 2023 学年第 1 学期金陵科技学院教务处制试验报告书写要求试验报告原则上要求学生手写,要求书写工整。假设因课程特点需打印的,标题承受四号黑体,正文承受小四号宋体,单倍行距。纸张 一律承受A4 的纸张。试验报告书写说明试验报告中试验目的和要求、试验仪器和设备、试验内容与过程、 试验结果与分析这四项内容为必需项。教师可依据学科特点和试验具体要求增加工程。填写留意事项(1) 细致观看,准时、准确、照实记录。(
2、2) 准确说明,层次清楚。(3) 尽量承受专用术语来说明事物。(4) 外文、符号、公式要准确,应使用统一规定的名词和符号。(5) 应独立完成试验报告的书写,严禁抄袭、复印,一经觉察, 以零分论处。试验报告批改说明试验报告的批改要准时、认真、认真,一律用红色笔批改。试验 报告的批改成绩承受五级记分制或百分制,按金陵科技学院课堂教学实施细则中作业批阅成绩评定要求执行。试验报告装订要求试验批改完毕后,任课教师将每门课程的每个试验工程的试验报 告以自然班为单位、按学号升序排列,装订成册,并附上一份该门课 程的试验大纲。金陵科技学院试验报告试验工程名称: C#根底编程试验学时:6同组学生姓名:试验地点:
3、A205试验日期: 9 月 17 日-9 月 24 日试验成绩:批改教师:批改时间:金陵科技学院试验报告试验 1 C#根底编程一、试验目的1、生疏 Visual Studio .NET 开发环境; 2、把握 C#应用程序的根本操作过程;3、把握 C#的数据类型,运算符以及表达式的使用;4、把握分支和循环语句的使用方法;5、把握一维数组,二维数组及数组型数组的使用。二、试验要求(1) 编写程序要标准、正确,上机调试过程和结果要有记录;(2) 做完试验后给出本试验的试验报告。三、试验设备、环境安装有 Visual Studio .NET 软件。四、试验步骤1、分析题意;2、依据题目要求,建工程;3
4、、编写并输入相关的程序代码;5、运行与调试工程;6、保存工程。五、试验内容1、编写一个简洁的把握台应用程序,打印一行文字(如你的姓名)。using System;using System.Collections.Generic; using System.Text;namespace Test1_1class Programstatic void Main(string args)Console.WriteLine(“1121412023 张明星!“); Console.ReadLine;2、编写一个简洁的 Windows 应用程序,在标签中显示你的姓名。Form 窗体的代码:using Sy
5、stem;using System.Collections.Generic;10using System ponentModel; using System.Data;using System.Drawing; using System.Text;using System.Windows.Forms;namespace w_1public partial class Form1 : Formpublic Form1InitializeComponent;private void button1_Click(object sender, EventArgs e)label2.Text = “你输
6、入的姓名:“+textBox1.Text; textBox2.Text = “你输入的姓名:“ + textBox1.Text; MessageBox.Show(“你输入的姓名:“ + textBox1.Text);3、编写一个一个程序,用来推断输入的是大写字母,小写字母,数字还是其他的字符。using System;using System.Collections.Generic; using System.Text;namespace Testclass Programstatic void Main(string args)char c; int i=0;while (i 10)Cons
7、ole.WriteLine(“请输入一个字符:“); c = Convert.ToChar(Console.ReadLine); i+;if (char.IsUpper(c)Console.WriteLine(c + “这是一个大写字母“);else if (char.IsLower(c)Console.WriteLine(c + “这是一个小写字母“);else if (char.IsDigit(c)elseConsole.WriteLine(c + “这是一个数字“);Console.WriteLine(c + “什么也不是!“);Console.ReadLine;4、分别用 while,
8、do-while,for 循环求 1 到 100 的和。using System;using System.Collections.Generic; using System.Text;namespace Testclass Programstatic void Main(string args)int sum = 0, i = 0;for (i = 1; i = 10; i+)sum = sum + i;dosum = sum + i; i+; while (i = 10);while (i = 10)sum = sum + i; i+;Console.WriteLine(“1到的和为“ +
9、 sum); Console.ReadLine;5、定义一个一维数组,用随机数为此赋值,用 foreach 循环输出其中的内容。using System;using System.Collections.Generic; using System.Text;namespace Test1_1class Programstatic void Main(string args)int a = new int10;Random ran = new Random; for(int i=0;i10;i+)ai=ran.Next(100); foreach(int i in a)Console.Write
10、Line(i+“ “);6、实现二维数组的输入和输出。using System;using System.Collections.Generic; using System.Text;namespace Testclass Programstatic void Main(string args)/输出100里的十个随机数int a = new int10; int, a = new int3, 3; for (int i = 0; i 3; i+)for (int j = 0; j 3; j+)ai, j = Convert.ToInt32(Console.ReadLine);for (int
11、 i = 0; i 3; i+)for (int j = 0; j 3; j+)Console.Write(ai, j + “ “); Console.Write(“n“);7、实现数组型数组的输入和输出。using System;using System.Collections.Generic; using System.Text;namespace Test1_1class Programstatic void Main(string args)int a = new int2;a0 = new int3 Convert.ToInt32(Console.ReadLine), Convert
12、.ToInt32(Console.ReadLine), Convert.ToInt32(Console.ReadLine) ;a1 = new int4 Convert.ToInt32(Console.ReadLine), Convert.ToInt32(Console.ReadLine), Convert.ToInt32(Console.ReadLine), Convert.ToInt32(Console.ReadLine) ;for (int j = 0; j 3; j+)Console.Write(a0j+“ “);Console.WriteLine(“n“); for (int j =
13、 0; j 4; j+)Console.Write(a1j + “ “);六、试验体会遇到问题及解决方法,编程后的心得体会试验工程名称:类与对象试验学时:6同组学生姓名:试验地点:A205试验日期: 9 月 24 日-10 月 1 日试验成绩:批改教师:批改时间:试验 2 类与对象一、试验目的、要求(1) 把握类的定义和使用;(2) 把握类的数据成员,属性的定义和使用;(3) 把握方法的定义,调用和重载以及方法参数的传递;(4) 把握构造函数的定义和使用。二、试验要求(1) 编写程序要标准、正确,上机调试过程和结果要有记录;(2) 做完试验后给出本试验的试验报告。三、试验设备、环境安装有 Vi
14、sual Studio .NET 软件。四、试验步骤1、分析题意;2、依据题目要求,建工程;3、编写并输入相关的程序代码;5、运行与调试工程;6、保存工程。五、试验内容1、定义一个方法,实现两个数的交换分别把参数按值传递和按引用传递; Form 里面的代码:using System;using System.Collections.Generic; using System ponentModel; using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace Test
15、1_1public partial class Form1 : Formpublic Form1InitializeComponent;private void btnSwap_Click(object sender, EventArgs e)Swaper s = new Swaper;int a = Convert.ToInt32(txtOne.Text); int b = Convert.ToInt32(txtTwo.Text); lblShow.Text = s.Swap(a,b);lblShow.Text += string.Format(“nn主调方法:条用之后:a=0,b=1“,a
16、,b); txtOne.Text = a.ToString;txtTwo.Text = b.ToString;class Swaperpublic string Swap(int x, int y)int temp; temp = x; x = y;y = temp;return string.Format(“被调方法:交换之后:x0=,y=1“,x,y);2、定义一个方法,实现数组的排序;using System;using System.Collections.Generic; using System.Text;namespace Test1_1class Programstatic v
17、oid Main(string args)SortLS s = new SortLS; int b = new int5;for (int i = 0; i 5; i+)bi = Convert.ToInt32(Console.ReadLine);s.SortL(b);Console.ReadLine;class SortLSpublic void SortL(int a)for (int i = 1; i a.Length; i+)int temp;if (ai-1 ai)temp = ai-1; ai-1 = ai; ai = temp;for (int i = 0; i a.Length
18、; i+)Console.Write(ai+“ “);3、定义一个学生类,把学生类当作对象来传递;using System;using System.Collections.Generic; using System.Text;namespace Test1_2class Programstatic void Main(string args)Student stu = new Student; stu.name = “张三“;stu.age = 20;stu.ShowMessage(stu);public class Studentpublic string name; public int
19、 age;public void ShowMessage(Student student)Console.WriteLine(“学生姓名:“+student.name+“ “+“年龄:“+student.age);4、定义一个方法,求两个数的和和差,通过参数把这两个值带回;using System;using System.Collections.Generic; using System.Text;namespace Test1_3class Programstatic void Main(string args)A ax = new A; int a, b;a = 10;b = 3;ax.
20、Method(a,b);class Apublic void Method( int x, int y)int add, miu; add = x + y; miu = x - y;Console.WriteLine(“两数之和:“ + add + “n“ + “两数之差:“ + miu);5、用构造函数重载,实现矩形的面积,圆的面积,梯形的面积;using System;using System.Collections.Generic; using System.Text;namespace Test1_4class Programstatic void Main(string args)i
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 程序设计 实验 报告
限制150内