前兩天有事,比較忙。基礎的視頻已經搞到全集的AVI,1元錢,爲了學習,花點小錢和時間,沒有問題。今天的任務!編程
vs2010 過時,用這個產品密鑰函數
vs 2010 產品密鑰
YCFHQ-9DWCY-DKV88-T2TMH-G7BHP學習
zy21
一、理解掌握函數的參數傳遞方式。
二、理解掌握函數參數的匹配。spa
//輸入兩個數比較他們的大小 static double Max(double a,double b ){ double c = (a > b) ? a : b; return c; } static void Main(string[] args) { double a = Convert.ToDouble(Console.ReadLine()); double b = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("a和b的最大值:{0}", Max(a, b)); }
//地址傳遞 static void Dou(int[]array ){ for (int i = 0; i < array.Length; i++) { array[i]= array[i]*2; } } static void Main(string[] args) { int []array={1,2,3,4,5,6}; Console.Write("Before:"); foreach (int nub in array) { Console.Write("\t" + nub); } Dou(array); Console.Write("\nAfter:"); foreach (int nub in array) { Console.Write("\t" + nub); }
//引用型傳遞交換函數參數的值 static void Sweep(ref int x, ref int y) { int temp = x; x = y; y = temp; } static void Main(string []args) { int x = 40; int y = 10; Console.WriteLine("old:x={0},y={1}",x,y); Sweep(ref x,ref y); Console.WriteLine("new:x={0},y={1}", x, y); }
//輸出型參數已知圓的半徑求圓的周長和麪積 static double Circle(double r, out double s) { double zc = 2*Math.PI*r; s = Math.PI * r * r; return zc; } static void Main(string []arges) { double r = 156,s; double zc=(Circle(r,out s)); Console.WriteLine("圓的周長:"+zc); Console.WriteLine("圓的面積"+s); }
//已知球的半徑,求球的體積,隱式轉換 static double CircleV(double r) { double v = (4/3)*Math.PI * r * r*r; return v; } static void Main(string []arges) { double r = 18.55; Console.WriteLine("圓的體積:"+CircleV(r)); int r1 = 20; Console.WriteLine("圓的面積"+CircleV(r1)); }
zy22
一、理解掌握函數的遞歸程序設計方法。
二、經過斐波那契數列的遞歸程序設計,更加深刻領會函數的遞歸。設計
//遞歸調用 static double fn(int n) { if (n <= 1) { return 1; } else { return n*fn(n-1); } } static void Main(string[] args) { int n = 5; Console.WriteLine(fn(n)); }
//斐波那契數列 static double Fiboncci(double n) { if ((n == 1) || (n == 2)) return 1;else return Fiboncci(n-1)+Fiboncci(n-2); } static void Main(string []a) { Console.WriteLine("你一共輸入了多少項"); int n = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Fiboncci:"); for (int i = 1; i <= n;i++ ) { Console.Write("{0}\t", Fiboncci(i)); if (i % 5 == 0) { Console.WriteLine(); } } }
zy23
一、認識局部變量,並掌握局部變量的做用域。
二、理解什麼是結構化編程思想。3d
zy24
一、瞭解面向對象編程的背景。
二、瞭解類,對類有個初步的印象。
三、瞭解封裝,對封裝有個初步的印象。
四、瞭解接口,對接口有個初步的印象。
五、瞭解對象,對對象有個初步的印象。視頻
zy25
一、掌握如何定義類。
二、認識字段和方法。
三、理解公有(public)和私有(private)兩種修飾符的運用。
四、掌握如何建立對象。
五、經過本課的學習初步理解類和對象。對象
using Oop_first; namespace Oop_first { class Program { static void Main(string[] args) { cat Kitty = new cat();//構造函數,叫作方法 Kitty.name = "Kitty"; Kitty.age = 3; Console.WriteLine("我是{0},我今年{1}歲",Kitty.name,Kitty.age); Kitty.Meow(); Kitty.cateCount(); Kitty.cateCount(); Kitty.cateCount(); Kitty.cateCount(); } } } namespace Oop_first { class cat { //public 公有的 private私有的 public string name;//字段 public int age; private int miceCount = 0; private void Hello() //方法 { Console.WriteLine( "嗨,我是:"+name); } public void Meow() { Hello(); Console.WriteLine("喵喵。。。。"); } public void cateCount() { Hello(); miceCount++; Console.WriteLine("一共抓住了{0}只老鼠",miceCount); } } }
zy26
一、瞭解爲何要使用屬性。
二、掌握屬性的定義和使用。
三、認識什麼是構造函數。
四、並掌握默認構造函數、有參構造函數、無參構造函數的使用。
zy27
一、瞭解什麼是析構函數。並掌握析構函數的程序設計
二、瞭解什麼是垃圾回收。
三、經過time類的設計,進一步鞏固咱們前面所學過的類的知識。blog
class Program { static void Main(string[] args) { //析構函數 Cat Kitty=new Cat("Kitty",3); Kitty.ZI(); Console.WriteLine("倒數第N句"); Console.WriteLine("。。。。。"); Console.WriteLine("倒數第二句"); Console.WriteLine("倒數第一句"); } } class Cat { private string name; private int age; public Cat(string nameValue, int ageValue) { name = nameValue; age = ageValue; Console.WriteLine("貓生了,調用了構造函數"); } ~Cat() { Console.WriteLine("這隻貓上天堂了"); } public void ZI() { Console.WriteLine("這隻貓的名字"+name); Console.WriteLine("這隻貓的年齡"+age); } }
class Time { private int hour; private int minute; private int second; private void Settime(int h ,int m,int s) { Hour = h; Minute = m; Second = s; } public Time() { Settime(0,0,0); } public Time(int hourValue) { Settime(hourValue, 0, 0); } public Time(int hourValue, int minuteValue, int secondValue) { Settime(hourValue, minuteValue, secondValue); } //三個類分別判斷有效性 public int Hour { get { return hour; } set { hour=(value>0&&value<24?value:0);} } public int Minute { get { return minute; } set { minute = (value > 0 && value < 60 ? value : 0); } } public int Second { get { return second; } set { second = (value > 0 && value < 60 ? value : 0); } } //方法24小時輸出 public string ToString24() { string output = Hour + ":" + Minute + ":" + Second; return output; } //12小時輸出 public string TonString12() { int hourTemp=((Hour==12)&&(Hour==0)?12:(Hour%12)); string AMPM=(Hour>12?"PM":"AM"); string output = hourTemp + ":" + Minute + ":" + Second + AMPM; return output; } } class Program { static void Main(string[] args) { Time time1 = new Time(); Time time2 = new Time(22); Time time3 = new Time(22,36,30); Console.WriteLine("time1:"); Console.WriteLine("二十四小時:"+time1.ToString24()); Console.WriteLine("十二小時:" + time1.TonString12()); Console.WriteLine("time2:"); Console.WriteLine("二十四小時:" + time2.ToString24()); Console.WriteLine("十二小時:" + time2.TonString12()); Console.WriteLine("time3:"); Console.WriteLine("二十四小時:" + time3.ToString24()); Console.WriteLine("十二小時:" + time3.TonString12()); } }
zy28-1 zy28-2
一、理解什麼是以對象爲成員。學會以對象爲成員的程序設計方法。
二、認識靜態變量和靜態函數,掌握靜態變量和靜態函數的程序設計方法。遞歸
{ class Time { private int hour; private int minute; private int second; private void Settime(int h ,int m,int s) { Hour = h; Minute = m; Second = s; } public Time() { Settime(0,0,0); } public Time(int hourValue) { Settime(hourValue, 0, 0); } public Time(int hourValue, int minuteValue, int secondValue) { Settime(hourValue, minuteValue, secondValue); } //三個類分別判斷有效性 public int Hour { get { return hour; } set { hour=(value>0&&value<24?value:0);} } public int Minute { get { return minute; } set { minute = (value > 0 && value < 60 ? value : 0); } } public int Second { get { return second; } set { second = (value > 0 && value < 60 ? value : 0); } } //方法24小時輸出 public string ToString24() { string output = Hour + ":" + Minute + ":" + Second; return output; } //12小時輸出 public string TonString12() { int hourTemp=((Hour==12)&&(Hour==0)?12:(Hour%12)); string AMPM=(Hour>12?"PM":"AM"); string output = hourTemp + ":" + Minute + ":" + Second + AMPM; return output; } } class Program { static void Main(string[] args) { Date birthday= new Date(1981,12,12,new Time(16,30,5)); Console.WriteLine("我出於{0}年{1}月{2}日{3}",birthday.year,birthday.month,birthday.day,birthday.colck.ToString24()); } } class Date { public int year=new int(); public int month; public int day; //int 的對象 public Time colck;//上面定義的Time 類colock是Time 類的對象必須要用構造函數的方法附值 public Date(int yearValue, int monthValue, int dayValue,Time timeValue) { year = yearValue; month = monthValue; day = dayValue; colck = timeValue; } }
zy29
一、掌握const常量成員在類中的程序設計。
二、認識readonly掌量成員,並學會它在類中的程序設計。
三、掌握const和readonly的區別。
zy30
一、認識什麼是重載。
二、掌握函數重載的程序設計方法。
三、掌握構造函數重載的程序設計方法。
namespace 函數的重載 { class program { static void Main(string[] arges) { int a=7, b=2; Console.WriteLine(Calculate.Value(a,b)); double c = 7, e = 2; Console.WriteLine(Calculate.Value(c, e)); } } class Calculate{ static public int Value(int x ,int y){ return x/y; } static public double Value(double x, double y) { return x / y; } }