C#程序设计实验报告
更新时间:2023-12-01 11:30:01 阅读量: 教育文库 文档下载
学 生 实 验 报 告
课程名称:
学生学号:
所属院部:
(理工类)
C#程序设计 专业班级: M11计算机科学与技术(专转本)
XXXXXXXX 学生姓名: XXX
信息技术学院 指导教师: XXX
2012 — 2013学年 第 1 学期
金陵科技学院教务处制
实验报告书写要求
实验报告原则上要求学生手写,要求书写工整。若因课程特点需打印的,标题采用四号黑体,正文采用小四号宋体,单倍行距。纸张一律采用A4的纸张。
实验报告书写说明
实验报告中实验目的和要求、实验仪器和设备、实验内容与过程、实验结果与分析这四项内容为必需项。教师可根据学科特点和实验具体要求增加项目。
填写注意事项
(1)细致观察,及时、准确、如实记录。 (2)准确说明,层次清晰。
(3)尽量采用专用术语来说明事物。
(4)外文、符号、公式要准确,应使用统一规定的名词和符号。 (5)应独立完成实验报告的书写,严禁抄袭、复印,一经发现,以零分论处。
实验报告批改说明
实验报告的批改要及时、认真、仔细,一律用红色笔批改。实验报告的批改成绩采用五级记分制或百分制,按《金陵科技学院课堂教学实施细则》中作业批阅成绩评定要求执行。
实验报告装订要求
实验批改完毕后,任课老师将每门课程的每个实验项目的实验报告以自然班为单位、按学号升序排列,装订成册,并附上一份该门课程的实验大纲。
金陵科技学院实验报告
实验项目名称: C#基础编程 实验学时: 6 同组学生姓名: 实验地点: 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、编写并输入相关的程序代码; 5、运行与调试项目; 6、保存项目。
五、实验内容
1、编写一个简单的控制台应用程序,打印一行文字(如你的姓名)。
using System;
using System.Collections.Generic; using System.Text;
namespace Test1_1 {
class Program {
static void Main(string[] args) {
Console.WriteLine(\张明星!\); Console.ReadLine(); } } }
2、编写一个简单的Windows应用程序,在标签中显示你的姓名。 Form窗体的代码:
using System;
using System.Collections.Generic;
1
金陵科技学院实验报告
using System.ComponentModel; using System.Data; using System.Drawing; using System.Text;
using System.Windows.Forms;
namespace w_1 {
public partial class Form1 : Form {
public Form1() {
InitializeComponent(); }
private void button1_Click(object sender, EventArgs e) {
label2.Text = \你输入的姓名:\+textBox1.Text; textBox2.Text = \你输入的姓名:\ + textBox1.Text; MessageBox.Show(\你输入的姓名:\ + textBox1.Text); } }
}
3、编写一个一个程序,用来判断输入的是大写字母,小写字母,数字还是其他的字符。
using System;
using System.Collections.Generic; using System.Text;
namespace Test {
class Program {
static void Main(string[] args) {
char c; int i=0; while (i < 10) {
Console.WriteLine(\请输入一个字符:\); c = Convert.ToChar(Console.ReadLine()); i++;
if (char.IsUpper(c)) {
2
金陵科技学院实验报告
Console.WriteLine(c + \这是一个大写字母\); }
else if (char.IsLower(c)) {
Console.WriteLine(c + \这是一个小写字母\); }
else if (char.IsDigit(c)) { } else {
Console.WriteLine(c + \什么也不是!\); }
}
Console.ReadLine();
} } }
Console.WriteLine(c + \这是一个数字\);
4、分别用while,do-while,for循环求1到100的和。
using System;
using System.Collections.Generic; using System.Text;
namespace Test {
class Program {
static void Main(string[] args)
{
int sum = 0, i = 0;
for (i = 1; i <= 10; i++) {
sum = sum + i; }
do {
sum = sum + i; i++;
} while (i <= 10);
3
金陵科技学院实验报告
while (i <= 10) {
sum = sum + i; i++; }
Console.WriteLine(\到的和为\ + sum);
Console.ReadLine(); } } }
5、定义一个一维数组,用随机数为此赋值,用foreach循环输出其中的内容。 using System;
using System.Collections.Generic; using System.Text;
namespace Test1_1 {
class Program {
static void Main(string[] args) {
int[] a = new int[10]; Random ran = new Random(); for(int i=0;i<10;i++) a[i]=ran.Next(100); foreach(int i in a) {
Console.WriteLine(i+\); } } } }
6、实现二维数组的输入和输出。
using System;
using System.Collections.Generic; using System.Text;
namespace Test {
class Program {
static void Main(string[] args)
{
//输出100里的十个随机数
4
金陵科技学院实验报告
int[] a = new int[10]; int[,] a = new int[3, 3]; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++)
a[i, j] = Convert.ToInt32(Console.ReadLine()); for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++)
Console.Write(a[i, j] + \); Console.Write(\);
}
} } }
7、实现数组型数组的输入和输出。
using System;
using System.Collections.Generic; using System.Text;
namespace Test1_1 {
class Program {
static void Main(string[] args) {
int[][] a = new int[2][];
a[0] = new int[3] { Convert.ToInt32(Console.ReadLine()), Convert.ToInt32(Console.ReadLine()), Convert.ToInt32(Console.ReadLine()) };
a[1] = new int[4] { 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(a[0][j]+\); }
Console.WriteLine(\); for (int j = 0; j < 4; j++) {
Console.Write(a[1][j] + \); } } } }
5
金陵科技学院实验报告
六、实验体会(遇到问题及解决办法,编程后的心得体会)
6
金陵科技学院实验报告
实验项目名称: 类与对象 实验学时: 6 同组学生姓名: 实验地点: A205 实验日期: 9月24日-10月1日 实验成绩: 批改教师: 批改时间:
7
金陵科技学院实验报告
实验2 类与对象
一、实验目的、要求
(1)掌握类的定义和使用;
(2)掌握类的数据成员,属性的定义和使用;
(3)掌握方法的定义,调用和重载以及方法参数的传递; (4)掌握构造函数的定义和使用。 二、实验要求
(1)编写程序要规范、正确,上机调试过程和结果要有记录; (2)做完实验后给出本实验的实验报告。 三、实验设备、环境
安装有Visual Studio .NET软件。 四、实验步骤
1、分析题意;
2、根据题目要求,新建项目; 3、编写并输入相关的程序代码; 5、运行与调试项目; 6、保存项目。 五、实验内容
1、定义一个方法,实现两个数的交换(分别把参数按值传递和按引用传递); Form里面的代码:
using System;
using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text;
using System.Windows.Forms;
namespace Test1_1 {
public partial class Form1 : Form {
public Form1() {
InitializeComponent(); }
private void btnSwap_Click(object sender, EventArgs e)
8
金陵科技学院实验报告
{
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(\主调方法:条用之后:a={0},b={1}\,a,b); txtOne.Text = a.ToString(); txtTwo.Text = b.ToString(); }
class Swaper {
public string Swap(int x, int y) {
int temp; temp = x; x = y; y = temp;
return string.Format(\被调方法:交换之后:x{0}=,y={1}\,x,y); } } }
}
2、定义一个方法,实现数组的排序; using System;
using System.Collections.Generic; using System.Text;
namespace Test1_1 {
class Program {
static void Main(string[] args) {
SortLS s = new SortLS(); int[] b = new int[5]; for (int i = 0; i < 5; i++) {
b[i] = Convert.ToInt32(Console.ReadLine()); } s.SortL(b);
Console.ReadLine(); }
class SortLS {
9
金陵科技学院实验报告
public void SortL(int[] a) {
for (int i = 1; i
int temp; if (a[i-1] < a[i]) {
temp = a[i-1]; a[i-1] = a[i]; a[i] = temp; } }
for (int i = 0; i < a.Length; i++) {
Console.Write(a[i]+\); } } } } }
3、定义一个学生类,把学生类当作对象来传递; using System;
using System.Collections.Generic; using System.Text;
namespace Test1_2 {
class Program {
static void Main(string[] args) {
Student stu = new Student(); stu.name = \张三\; stu.age = 20;
stu.ShowMessage(stu); }
public class Student {
public string name; public int age;
public void ShowMessage(Student student) {
10
金陵科技学院实验报告
Console.WriteLine(\学生姓名:\+student.name+\+\年龄:\+student.age); } } } }
4、定义一个方法,求两个数的和和差,通过参数把这两个值带回; using System;
using System.Collections.Generic; using System.Text;
namespace Test1_3 {
class Program {
static void Main(string[] args) {
A ax = new A(); int a, b; a = 10; b = 3;
ax.Method(a,b); } class A {
public void Method(int x, int y) {
int add, miu; add = x + y; miu = x - y;
Console.WriteLine(\两数之和:\ + add + \ + \两数之差:\ + miu); } } } }
5、用构造函数重载,实现矩形的面积,圆的面积,梯形的面积;
using System;
using System.Collections.Generic; using System.Text;
namespace Test1_4 {
class Program {
11
金陵科技学院实验报告
static void Main(string[] args) {
int a = 4; int b = 5; int c = 6;
Area a1 = new Area(a); Area a2 = new Area(a,b); Area a3 = new Area(a,b,c); } class Area {
int x, y, z; public Area(int a) {
Console.WriteLine(\圆的面积:\+ 3.12 * a*a); }
public Area(int a,int b) {
Console.WriteLine(\矩形的面积:\ + a*b); }
public Area(int a,int b,int h) {
Console.WriteLine(\梯形的面积:\ + (a+b)*h/2); } } } }
6、设计一个windows应用程序,在该程序中定义一个学生类和班级类,以处理每个学生的学号,姓名,语文,数学和英语成绩,要求:
1)能查询每个学生的总成绩。 2)能显示全班前三名的名单。
3)能显示单科成绩最高分和不及格的学生名单。 4)能统计全班学生的平均成绩。
5)能显示各科成绩不同分数段的学生人数的百分比。 Student类:
using System;
using System.Collections.Generic; using System.Text;
namespace Test4_3 {
12
正在阅读:
C#程序设计实验报告12-01
教师资格证考试资料--心理学复习试题107-02
2020年整合CT医师上岗考试头颅练习题名师精品资料03-10
描写樱花小学生二年级作文06-13
Oracle 作业(1)06-30
多普勒效应综合试验10-04
合同解除有无溯及力之争有待休矣 以意大利法为视角的再思考03-29
世格外贸单证教学系统答案04030105-11
中医实践技能应试指南06-18
春雨的色彩教案08-05
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- C#
- 程序设计
- 实验
- 报告
- 推荐学习K122018北师大版高中数学必修三学案:第二章 1 算法的基本思想
- 支行20XX年工作计划
- 上海市住宅建筑设计总结(中间版)
- 家校共建 携手共育
- 公共心理学课程标准
- 会计专业暑期实习报告
- 医院医疗核心制度复习题及答案
- 毛概材料分析题
- scorm Api 开发技术文档
- 国家开放大学电大专科《财务管理》2019-2020期末试题及答案(试卷号:2038) -
- 我心中的鲁迅先生
- 市场营销学试题与答案2
- 基础会计习题集及参考答案
- (词义选择译文)
- 中考物理试题电学压轴题之多档位问题 - 图文
- 流体力学课后作业
- 《网店客服》
- 西方经济学流派
- 2014下半年及2015上半年中国化工新建项目大全(合订版)- 副本
- 四年级心理健康教育教案