欢迎来到冰点文库! | 帮助中心 分享价值,成长自我!
冰点文库
全部分类
  • 临时分类>
  • IT计算机>
  • 经管营销>
  • 医药卫生>
  • 自然科学>
  • 农林牧渔>
  • 人文社科>
  • 工程科技>
  • PPT模板>
  • 求职职场>
  • 解决方案>
  • 总结汇报>
  • ImageVerifierCode 换一换
    首页 冰点文库 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

    c#程序设计实验报告.docx

    • 资源ID:11078439       资源大小:166.75KB        全文页数:28页
    • 资源格式: DOCX        下载积分:3金币
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    二维码
    微信扫一扫登录
    下载资源需要3金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    c#程序设计实验报告.docx

    1、c#程序设计实验报告实验报告二姓 名专业软件工程课程名称C#程序设计一、实验名称:实验2二、实验目的:掌握使用命令行开发简单的C#应用程序掌握使用Visual Studio编写控制台应用程序掌握Visual Studio环境下程序的跟踪调试了解Visual Studio在线帮助的使用掌握应用程序命令行参数的使用三、实验内容及要求利用ADO.NET完成数据的增、删、改、查1.1 鼠标、窗口、菜单的操作1.2 用户账户的管理1.3 桌面图标的排列、设置桌面背景和屏幕保护程序1.4 设置任务栏、语言栏1.5 选择输入法、在记事本”文件中输入各种符号2.1了解资源管理器的使用”2.2 设置文件夹选项、

    2、查找文件或文件夹2.3 文件/文件夹操作2.4 使用回收站具体要求请见大学计算机应用基础学习指导P37P48四、实验材料、工具、或软件Windows *P Professional SP3Visual Studio 2005五、实验步骤、结果(或记录)实验二:程序流程控制2-1输入半径,求对应的圆的周长、面积、对应球体的体积。运行结果:实验代码:using System;using System.Collections.Generic;using System.Linq;using System.Te*t;namespace _2_1 class Program static void Mai

    3、n(string args) const double PI = 3.14159; double r, perimeter, area, volume; Console.Write (请输入半径:); String s = Console.ReadLine(); r = double.Parse(s); Console.WriteLine(圆的半径为=0,r); perimeter = 2 * PI * r; area = PI * r * r; volume = 4 / 3 * PI * Math.Pow(r, 3); Console.WriteLine(圆的周长为=0,面积为=1,peri

    4、meter ,area ); Console.WriteLine(球体的体积=0,volume ); Console.ReadLine(); 2-2求三角形的周长和面积运行结果:实验代码:using System;using System.Collections.Generic;using System.Linq;using System.Te*t;namespace _2_2 class Program static void Main(string args) double a, b, c, p, h, area; Console.Write(请输入三角形的边a:); string s =

    5、 Console.ReadLine(); a = double.Parse(s); Console .Write (请输入三角形的边b:); s = Console.ReadLine(); b = double.Parse(s); Console.Write(请输入三角形的边c:); s = Console.ReadLine(); c = double.Parse(s); if (a 0 & b 0 & c 0 & a + b c & a + c b & b + c a) Console.WriteLine(三角形三边分别为:a=0,b=1,c=2,a,b,c); p = a + b + c;

    6、 h = p / 2; area = Math.Sqrt(h * (h - a) * (h - b) * (h - c); Console.WriteLine(三角形的周长=0,面积为=1,p,area); else Console.WriteLine(无法构成三角形!); Console.ReadKey(); 2-3分段函数的实现运行结果实验代码:using System;using System.Collections.Generic;using System.Linq;using System.Te*t;namespace _2_3_2 class Program static void

    7、 Main(string args) double *, y; Console .Write (请输入*:); string s = Console.ReadLine(); * = double.Parse(s); y = (* * * - 3 * *) / (* + 1) + 2 * Math.PI + Math.Sin(*); if(*=0) y = (* * * - 3 * *) / (* + 1) + 2 * Math.PI + Math.Sin(*); if(*=0) y = (* * * - 3 * *) / (* + 1) + 2 * Math.PI + Math.Sin(*);

    8、 else y=Math.Log(-5*)+6*Math .Sqrt (Math .Abs (*)+Math .Pow (Math .E,4)-Math .Pow (*+1,3); Console .WriteLine (方法三:*=0,y=1,*,y); y=(*=0)(* * * - 3 * *) / (* + 1) + 2 * Math.PI + Math.Sin(*):Math.Log(-5*)+6*Math .Sqrt (Math .Abs (*)+Math .Pow (Math .E,4)-Math .Pow (*+1,3); Console .WriteLine (方法四:*=0

    9、,y=1,*,y); Console .ReadKey (); 2-4三个数比较大小运行结果:实验代码:using System;using System.Collections.Generic;using System.Linq;using System.Te*t;namespace _2_4 class Program static void Main(string args) int a, b, c, a1, b1, c1, t, Nma*, Nmin, Nmid; Random rMun = new Random(); a = rMun.Ne*t(101); b = rMun.Ne*t

    10、(101); c= rMun.Ne*t(101); Console.WriteLine(原始值:a=0,b=1,c=2,a,b,c); a1 = a; b1 = b; c1 = c; if (a b) t = a; a = b; b = t; if (a c) t = a; a = c; c = t; if (b c) t = b; b = c; c = t; Console.WriteLine(方法一)升序值:a=0,b=1,c=2),a,b,c); a = a1; b = b1; c = c1; Nma* =Math .Ma* (Math .Ma* (a,b),c); Nmin = Mat

    11、h.Min(Math.Min(a, b), c); Nmid = a + b + c - Nma* - Nmin; a = Nmin; b = Nmid; c = Nma*; Console.WriteLine(方法二)升序值:a=0,b=1,c=2,a,b,c); Console.ReadKey(); 2-5求解一元二次方程运行结果:实验代码:using System;using System.Collections.Generic;using System.Te*t;namespace Console2_5 class Program static void Main(string arg

    12、s) double a, b, c, delta, *1, *2, realPart, imagePart; Console.Write(请输入系数a:); String s = Console.ReadLine(); a = double.Parse(s); Console.Write(请输入系数b:); s = Console.ReadLine(); b = double.Parse(s); Console.Write(请输入系数c:); s = Console.ReadLine(); c = double.Parse(s); if(a=0) if(b=0) Console.WriteLi

    13、ne(此方程无解!); else Console.WriteLine(此方程的解为:0,-c/b); else delta=b*b-4*a*c; if(delta0) *1=(-b+Math.Sqrt(delta)/(2*a); *2=(-b-Math.Sqrt(delta)/(2*a); Console.WriteLine(此方程有两个不等实根:0,1,*1,*2); else if(delta =0)Console.WriteLine(此方程有两个相等实根:0,-b/(2*a); else realPart=-b/(2*a); imagePart=Math.Sqrt(-delta)/(2*

    14、a); Console.WriteLine(此方程有两个不等实根:0+1i和0-1i,realPart,imagePart); Console.ReadKey(); 2-6switch语句实现多重分支运行结果:实验代码:using System;using System.Collections.Generic;using System.Te*t;namespace ConsoleApplication1 class Program static void Main(string args) int i; Console.Write(输入一个数字(17):); String s = Consol

    15、e.ReadLine(); i = int.Parse(s); switch(i) case 1: Console.WriteLine(对应的星期为:星期一); break; case 2: Console.WriteLine(对应的星期为:星期二); break; case 3: Console.WriteLine(对应的星期为:星期三); break; case 4: Console.WriteLine(对应的星期为:星期四); break; case 5: Console.WriteLine(对应的星期为:星期五); break; case 6: Console.WriteLine(对应

    16、的星期为:星期六); break; case 7: Console.WriteLine(对应的星期为:星期日); break; default: Console.WriteLine(输入错误!); break ; Console.ReadKey(); 2-7分别使用if语句和switch语句实现多分支结构方法一:运行结果(if语句)using System;using System.Collections.Generic;using System.Te*t;namespace Console2_7 class Program static void Main(string args) int

    17、c; double f = 0; Console.Write(请输入有固定工资收入的党员的月工资:); int salary = int.Parse(Console.ReadLine(); if (salary 1500) c = 15; else c = (salary - 1) / 100; switch (c) case 0: case 1: case 2: case 3: f = 0.5 / 100 * salary; break; case 6: case 7: f = 1.5 / 100 * salary; break; case 8: case 9: case 10: case

    18、11: case 12: case 13: case 14: f = 2.0 / 100 * salary; break; case 15: f = 3.0 / 100 * salary; break; Console.WriteLine(月工资=0,交纳党费=1, salary, f); Console.ReadKey(); 法二运行结果:代码:(if语句)using System;using System.Collections.Generic;using System.Linq;using System.Te*t;namespace _2_7_2 class Program static

    19、 void Main(string args) int c; double f = 0; Console.Write(请输入有固定收入的党员的月工资:); int salary = int.Parse(Console.ReadLine(); if (salary 0 & salary 400 & salary 600 & salary 800 & salary 1500) f = 3.0 / 100 * salary; else Console.WriteLine(月工资输入有误!); Console.WriteLine(月工资=0,交纳党费=1, salary, f); Console.Re

    20、adKey(); 实验三:3-1运行结果:实验代码:using System;using System.Collections.Generic;using System.Linq;using System.Te*t;namespace _3_1 class Program static void Main(string args) int i, n, fac = 1; string s; n = -1; while (n 0) Console.Write(请输入非负整数n:); s = Console.ReadLine(); n = int.Parse(s); /方法一:for循环 for (

    21、i = 1; i = n; i+) fac *= i; Console.WriteLine( For循环:0!=1, n, fac); /方法二:while语句循环 i = 1; fac = 1; while (i = n) fac *= i+; Console.WriteLine( while循环:0!=1, n, fac); /方法三:do.while语句循环 i = 1; fac = 1; do fac *= i; i+; while (i = n); Console.WriteLine( do.while循环:0!=1, n, fac); Console.ReadKey(); 3-2运

    22、行结果:实验代码:using System;using System.Collections.Generic;using System.Linq;using System.Te*t;namespace _3_2 class Program static void Main(string args) int f1 = 1, f2 = 1, f3, num = 2; Console.Write(0,5t0,5t, f1, f2); f3 = f1 + f2; while (f3 = 10000) Console.Write(0,5t, f3); num+; if (num % 5 = 0) Con

    23、sole.WriteLine(); f1 = f2; f2 = f3; f3 = f1 + f2; Console.ReadKey(); 3-3、鸡兔同笼问题运行结果:代码:using System;using System.Collections.Generic;using System.Linq;using System.Te*t;namespace _3_3 class Program static void Main(string args) int c, r; Console.Write(请输入总头数:); string s = Console.ReadLine(); int h =

    24、 int.Parse(s); int f = 1; while (f % 2 != 0) Console.Write(请输入总脚数(必须是偶数):); s = Console.ReadLine(); f = int.Parse(s); /方法一:利用循环 bool solution = false; for (c = 0; c =0&c=0) Console .WriteLine (方法二:鸡:0只,兔:1只,c ,r); solution =true ; if (!solution) Console.WriteLine(方法二:无解,请重新运行测试!); Console .ReadKey (

    25、); 3-4利用级数和求PI运行结果:实验代码:using System;using System.Collections.Generic;using System.Linq;using System.Te*t;namespace Consolejishuhe3_4 class Program static void Main(string args) float n, t,pi; int s; pi = 0; t = 1; n = 1; s = 1; while (Math.Abs(t) = Math.Pow(10, -6) pi += t; n += 2; s = -s; t = s / n; pi *= 4; Console.WriteLine(pi=0, pi); Console.ReadKey(); 3-5运行结果:实验代码:using System;using System.Collections.Generic;using System.Linq;using System.Te*t;namespace ConsoleG_3_6 class Program static void Main(string args)


    注意事项

    本文(c#程序设计实验报告.docx)为本站会员主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2023 冰点文库 网站版权所有

    经营许可证编号:鄂ICP备19020893号-2


    收起
    展开