资源描述:
《C#代码 课后习题代码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、第一章:习题一、习题二usingSystem;usingSystem.Collections.Generic;namespaceWindowsFormsApplication2usingSystem.Linq;usingSystem.Text;publicForm1(){InitializeComponent();}namespaceConsoleApplication1privatevoidbutton1_Click(objectsender,EventArgse){classProgram{label1.Font=newFont("华文彩云",80);
2、{staticvoidMain(string[]args)label1.ForeColor=System.Drawing.Color.Blue;{Console.WriteLine("HelloWorld!");button1.Enabled=false;}}}Console.Read();}}}}第二章习题二privatevoidbutton1_Click(objectsender,EventArgse){Strings,a;s=Convert.ToString(textBox1.Text);a=s.ToUpper();textBox1.Text=a.T
3、oString();}privatevoidbutton2_Click(objectsender,EventArgse){Strings,a;s=Convert.ToString(textBox1.Text);a=s.ToLower();textBox1.Text=a.ToString();}}}习题六privatevoidbutton1_Click(objectsender,EventArgse){stringa;a=Convert.ToString(textBox1.Text);MessageBox.Show(Convert.ToString(a)+"
4、,欢迎进入C#的世界!","欢迎进入C#的世界!",MessageBoxButtons.OK,MessageBoxIcon.Information);}习题三privatevoidbutton1_Click(objectsender,EventArgse){inta,b,c,d,x;x=Convert.ToInt32(textBox1.Text);a=x/1000;b=x/100-a*10;c=x/10-a*100-b*10;d=x%10;textBox2.Text=Convert.ToString(a);textBox3.Text=Convert.ToS
5、tring(b);textBox4.Text=Convert.ToString(c);textBox5.Text=Convert.ToString(d);}习题四银行贷款的月还额privatevoidbutton1_Click(objectsender,EventArgse){doublep,r,a,b;intn;p=Convert.ToDouble(textBox1.Text);r=Convert.ToDouble(textBox2.Text);n=Convert.ToInt32(textBox3.Text);b=Math.Pow((1+r),n);a=
6、p*r*b/(b-1);textBox4.Text=a.ToString(".##");}习题五、随机数privatevoidbutton1_Click(objectsender,EventArgse){Randomintra=newRandom();inta=intra.Next(1,101);charb=(char)a;textBox1.Text=Convert.ToString(a);textBox2.Text=Convert.ToString(b);}第三章习题二是否是闰年privatevoidbutton1_Click(objectsender,
7、EventArgse){inta;a=Convert.ToInt32(textBox1.Text);if(a%4==0&&a%100!=0
8、
9、a%400==0)label2.Text="闰年";elselabel2.Text="不是闰年";}习题三一元二次方程组privatevoidbutton1_Click(objectsender,EventArgse){inta,b,c;doublex;a=Convert.ToInt32(textBox1.Text);b=Convert.ToInt32(textBox2.Text);c=Convert.ToInt32
10、(textBox3.Text);x=Math.Pow(b,2);i