ImageVerifierCode 换一换
格式:DOC , 页数:43 ,大小:440.50KB ,
资源ID:5910032      下载积分:10 金币
快捷注册下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/5910032.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请

   平台协调中心        【在线客服】        免费申请共赢上传

权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

注意事项

本文(c#程序设计教程第二版李春葆课后编程题答案.doc)为本站上传会员【xrp****65】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

c#程序设计教程第二版李春葆课后编程题答案.doc

1、输入a,b求c = a + b using System; using System.Collections.Generic; using System.Text; namespace Proj2_1 { class Program { static void Main(string[] args) { int a, b, c; Console.Write("a:"); a = int.Parse( Console.ReadLine());

2、 Console.Write("b:"); b = int.Parse(Console.ReadLine()); c = a + b; Console.WriteLine("a+b={0}", c); } } } using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; us

3、ing System.Text; using System.Windows.Forms; namespace Proj2_2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { int a, b, c;

4、 a = Convert.ToInt16(textBox1.Text); b = Convert.ToInt16(textBox2.Text); c = a + b; textBox3.Text = Convert.ToString(c); } private void Form1_Load(object sender, EventArgs e) { } private void textBo

5、x2_TextChanged(object sender, EventArgs e) { } } } 强制转换P38 using System; using System.Collections.Generic; using System.Text; namespace Proj3_1 { class Program { static void Main(string[] args) { int i=65,i1,i2;

6、 double d = 66.3456,d1,d2; char c = 'A',c1,c2; Console.WriteLine("i={0:d5},d={1:f},c={2}", i, d, c); i1 = (int)d; //强制类型转换 d1 = i;      //隐式类型转换 c1 = (char)i;  //强制类型转换 Console.WriteLine("i1={0:d5},d1={1:f

7、},c1={2}", i1, d1, c1); i2 = c; //隐式类型转换 d2 = (int)d; //强制类型转换 c2 = (char)d; //强制类型转换 Console.WriteLine("i2={0:d5},d2={1:f},c2={2}", i2, d2, c2); } } } 赋值两同学信息数据,并在图中输出结果P44 using System; namespace P

8、roj3_2 { class Program { struct Student //类型声明应放在Main函数的外面 {  public int xh; //学号 public string xm; //姓名 public string xb; //性别 public int nl; //年龄 public string bh; //班号 } static void Main(string[] arg

9、s) { Student s1,s2; //定义两个结构类型变量 s1.xh = 101; s1.xm = "李明"; s1.xb = "男"; s1.nl = 20; s1.bh = "07001"; Console.WriteLine("学号:{0},姓名:{1},性别:{2},年龄:{3},班号:{4}", s1.xh, s1.xm, s1.xb, s1.nl, s1.bh);

10、 s2 = s1; //将结构变量s1赋给s2 s2.xh = 108; s2.xm = "王华"; Console.WriteLine("学号:{0},姓名:{1},性别:{2},年龄:{3},班号:{4}", s2.xh, s2.xm, s2.xb, s2.nl, s2.bh); } } } 声明枚举类型color,给两成员赋值,定义三个变量,赋值运算输出相应值。P47 using System; using System.Collections.Generic

11、 using System.Text; namespace Proj3_3 { class Program { enum Color { Red=5, Green, Blue, White=1, Black } //类型声明应放在Main函数的外面 static void Main(string[] args) { Color c1, c2,c3; Console.WriteLine("Red={0},Green={1},Blue={2},White={3}

12、Black={4}",Color.Red,Color.Green,Color.Blue,Color.White,Color.Black); Console.WriteLine("Red={0},Green={1},Blue={2},White={3},Black={4}",(int)Color.Red,(int)Color.Green,(int)Color.Blue,(int)Color.White,(int)Color.Black); c1 = Color.Red; c2 = c1 + 1;

13、 c3 = c2 + 1; Console.WriteLine("c1={0},c2={1},c3={2}", c1, c2,c3); Console.WriteLine("c1={0},c2={1},c3={2}", (int)c1, (int)c2,(int)c3); } } } 位运算符运用P50 using System; using System.Collections.Generic; using System.Text; namespace Proj3_4 {

14、class Program { static void Main(string[] args) { byte b1, b2, b3; b1 = 10; b2 =(byte) ~b1; Console.WriteLine(b2); b3 = (byte)(b1 << 2); Console.WriteLine(b3); b1 = 3; b2 = 6;

15、 b3 = (byte)(b1 & b2); Console.WriteLine(b3); b3 = (byte)(b1 ^ b2); Console.WriteLine(b3); b3 = (byte)(b1 | b2); Console.WriteLine(b3); } } } 输出常用数据类型所用字节数P52 using System; using System.Collectio

16、ns.Generic; using System.Text; namespace Proj3_5 { class Program { static void Main(string[] args) { Console.WriteLine("byte类型所占字节数:{0}", sizeof(byte)); Console.WriteLine("char类型所占字节数:{0}", sizeof(char)); Console.WriteLine("int类

17、型所占字节数:{0}", sizeof(int)); Console.WriteLine("float类型所占字节数:{0}", sizeof(float)); Console.WriteLine("double类型所占字节数:{0}", sizeof(double)); Console.WriteLine("decimal类型所占字节数:{0}", sizeof(decimal)); } } } 求字符串子串在主串的位置P56 using System; using System.Col

18、lections.Generic; using System.Text; namespace Proj3_6 { class Program { static void Main(string[] args) { String mstr,sstr; Console.Write("输入主串:"); mstr = Console.ReadLine(); Console.Write("输入子串:"); ss

19、tr = Console.ReadLine(); Console.WriteLine("主串长度={0},子串长度={1}", mstr.Length, sstr.Length); if (String.Compare(mstr, sstr) != 0) Console.WriteLine("位置:{0}", mstr.IndexOf(sstr)); else Console.WriteLine("两个字符串相

20、同"); } } } DataTime结构的使用P59 using System; namespace Proj3_7 { class Program { static void Main(string[] args) { DateTime d1 = DateTime.Now; //定义当前日期时间变量 DateTime d2 = new DateTime(2009, 10, 1); //定义一个日期时间

21、变量 Console.WriteLine("d1:{0}",d1); int i = d1.Year; int j = d1.Month; int k = d1.Day; int h = d1.Hour; int m = d1.Minute; int s = d1.Second; Console.WriteLine("d1:{0}年{1}月{2}日{3}时{4}分{5}秒", i,j,k,

22、h,m,s); Console.WriteLine("d2:{0}",d2); Console.WriteLine("相距时间:{0}",d2 - d1); DateTime d3 = d1.AddDays(100); //d3为d1的100天后的日期 Console.WriteLine("d3:{0}",d3); Console.WriteLine(DateTime.IsLeapYear(i)); Console.WriteLine(

23、DateTime.IsLeapYear(d2.Year)); } } } 设计一个控制台程序,定义变量int a,b;float x,y。并求表达式(float)(a+b)/+(int)x%(int)y P60 using System; using System.Collections.Generic; using System.Text; namespace Proj3_8 { class Program { static void Main(string[] args) {

24、 int a = 2, b = 3; float x = 3.5f, y = 2.5f; Console.WriteLine("{0}", (float)(a + b) / 2 + (int)x % (int)y); } } } 设计一个控制台程序,定义变量int a,b, c;并求表达式(++c-1)&b+c/2 P60 using System; using System.Collections.Generic; using System.Text; namespace Proj3

25、9 { class Program { static void Main(string[] args) { int a = 3, b = 4, c = 5; Console.WriteLine("{0}", (++c - 1) & b + c / 2); } } } 声明一个学生结构类型Stud,包含学号,姓名,出生日期成员,定义Stud结构的两个学生变量S1,S2并赋值,求他们出售在星期几及其相差天数P60 using System; using

26、 System.Collections.Generic; using System.Text; namespace Proj3_10 {enum WeekDayhz {星期日,星期一,星期二,星期三,星期四,星期五,星期六}; class Program { struct Stud //结构类型声明应放在Main函数的外面 { public int xh; //学号 public string xm; //姓名 public DateTime birthday; //出生日期

27、 } static void Main(string[] args) { Stud s1, s2; s1.xh = 100; s1.xm = "李明"; s1.birthday = new DateTime(1985,10,18); s2.xh = 200; s2.xm = "王丽"; s2.birthday = new DateTime(1986,2,16); int i = (int)s1.birthday.DayOfWeek; Console.Wr

28、iteLine("{0}出生在{1}",s1.xm,(WeekDayhz)i); i = (int)s2.birthday.DayOfWeek; Console.WriteLine("{0}出生在{1}", s2.xm, (WeekDayhz)i); Console.WriteLine("{0}和{1}相差{2}天", s1.xm, s2.xm, s2.birthday - s1.birthday); } } } 输入一组整数(以输入0结束)分别输出其中奇数和偶数之和 P72 usi

29、ng System; using System.Collections.Generic; using System.Text; namespace Proj4_13 { class Program { static void Main(string[] args) { int n,s1=0,s2=0; do { n = int.Parse(Console.ReadLine()); i

30、f (n%2==1) s1 += n; else s2 += n; } while (n!=0); Console.WriteLine("奇数之和={0}",s1); Console.WriteLine("偶数之和={0}",s2); } } } 输入正整数n,计算s=1+(1+2)+(1+2+3)+…+(1+2+3+…+n) using System; using

31、 System.Collections.Generic; using System.Text; namespace Proj4_14 { class Program { static void Main(string[] args) { int n,i,j,s=0; Console.Write("n:"); n = int.Parse(Console.ReadLine()); for (i = 1; i <= n; i++)

32、 for (j = 1; j <= i; j++) s += j; Console.WriteLine("s={0}", s); } } } 输出n阶杨辉三角形,n不能大于13 using System; using System.Collections.Generic; using System.Text; namespace Proj4_15 { class Program { static

33、void Main(string[] args) { int i,j,c,n; Console.Write("n:"); n=int.Parse(Console.ReadLine()); if (n>13) Console.WriteLine("输入的数值太大!"); else { for (i=0;i<=n-1;i++)

34、 { for (j=1;j<15-i;j++) Console.Write(" "); //每次循环显示2个空格 c=1; Console.Write("{0} ",c); for (j=1;j<=i;j++) { c=c*(i-j+1)/j;

35、 if (c<100) if (c<10) Console.Write("{0} ",c); //显示3个空格 else Console.Write("{0} ",c); //显示2个空格 else Con

36、sole.Write("{0} ",c); //显示1个空格 } Console.WriteLine(); } } } } } 利用π/4 = 1-1/3+1/5-1/7+…+1/(4n-3)-1/(4n-1) using System; using System.Collections.Generic; using System.Text; namespace Proj4_16 {

37、 class Program { static void Main(string[] args) { double pi=0.0; int i; for (i=1;i<=2000;i++) if (i%2==1) pi=pi+1.0/(2*i-1); else pi=pi-1.0/(2*i-1);

38、 pi=4*pi; Console.WriteLine("π={0}", pi); } } } 输出三个数,其数值刚好等于其每个数字立方和(153=1³+5³+3³) using System; using System.Collections.Generic; using System.Text; namespace Proj4_17 { class Program { static void Main(string[] args) {

39、 int i, n, a, b, c; for (i = 100; i <= 999; i++) { n = i; c = n % 10; n = n / 10; b = n % 10; n = n / 10; a = n; if (a * a * a + b * b * b + c * c * c == i) {

40、 Console.WriteLine("{0} {1} {2} = {3}", a, b, c,a*a*a+b*b*b+c*c*c); //Console.Write("{0} ", i); } } Console.WriteLine(); } } } 假设十个整数用一个一维数组存放,求其最大值和次大值 using System; using System.Collections.Generi

41、c; using System.Text; namespace Proj5_6 { class Program { static void Main(string[] args) { int[] a = new int[10]{1,8,3,4,7,9,6,10,2,5}; int n=10,max1,max2,i; max1=a[0]>a[1]?a[0]:a[1]; max2=a[0]>a[1]?a[1]:a[0];

42、 for (i=2;i

43、using System.Collections; using System.Collections.Generic; using System.Text; namespace Proj5_7 { class Program { static void Main(string[] args) { const int Max = 5; //考生数 int[] Ave = new int[Max];

44、 //定义一个一维数组存储考生的总成绩 int[,] grade={{88,75,62,84},{96,85,75,92}, //定义二维数组存储考生成绩 {68,63,72,78},{95,89,76,98}, {76,65,72,63}}; for(int i=0; i

45、 { Ave[i] += grade[i,j]; //累加考生成绩 } } for (int k = 0; k < Max; k++) Console.WriteLine("考生{0}平均成绩={1} ",k+1, Ave[k]/4.0); } } } 用两个一维数组分别存放5个学生的学号和姓名,分别按学号好姓名进行排序,输出排序后结果 using S

46、ystem; using System.Collections.Generic; using System.Text; namespace Proj5_8 { class Program { const int Max = 5; static void disp(int[] no,string[] name,string str) { Console.WriteLine(str); Console.Write("学号:\t"); f

47、or (int i = 0; i < no.Length; i++) Console.Write("{0}\t",no[i]); Console.WriteLine(); Console.Write("姓名:\t"); for (int i = 0; i < name.Length; i++) Console.Write("{0}\t", name[i]); Console.WriteLine(); }

48、 static void Main(string[] args) { int[] no = new int[] { 2, 4, 5, 1, 3}; string[] name = new string[] {"Smith","John","Mary","Cherr","Tomn"}; disp(no, name,"排序前:"); Array.Sort(no, name); disp(no, name,"按学号排序后:");

49、 Array.Sort(name, no); disp(no, name, "按姓名排序后:"); } } } 计算器 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Prj8_3 {

50、 public partial class Form1 : Form { private string s; private double x, y; private Button btn; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { tex

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服