CHAPTER VC#

Similar documents
untitled

1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET NET Framework.NET Framework 2.0 ( 3 ).NET Framework 2.0.NET F

CHAPTER 1

3.1 num = 3 ch = 'C' 2

Microsoft Word - 第3章.doc

CC213

FY.DOC

untitled

untitled

新・解きながら学ぶJava

Microsoft Word - 01.DOC

C/C++语言 - C/C++数据

Microsoft PowerPoint - OPVB1基本VB.ppt

C C

概述

untitled

C/C++ - 函数

C/C++ 语言 - 循环

第一章 章标题-F2 上空24,下空24

c_cpp

新版 明解C++入門編

WWW PHP Comments Literals Identifiers Keywords Variables Constants Data Types Operators & Expressions 2

数据结构与算法 - Python基础

5. 閱 讀 下 文, 推 斷 內 最 適 合 填 入 的 詞 語 依 序 為 何? 人 也 真 是 一 個 絕 字, 一 邊 向 左, 一 邊 向 右, 一 副 的 樣 子, 偏 又 相 連 著, 各 說 各 話 各 走 各 路, 卻 又 人, 這 麼 一 個 簡 單 的 字, 竟 包 含 如 此

untitled

C/C++语言 - 运算符、表达式和语句

C/C++程序设计 - 字符串与格式化输入/输出

Microsoft Word - ch04三校.doc

KillTest 质量更高 服务更好 学习资料 半年免费更新服务

第3章.doc

論鄭玄對《禮記‧月令》的考辨

2009年挑战乔戈里

穨文件1

戲劇研究 創刊號 詞之雅化 實為 折子戲 源生之三個重要背景 歷代戲曲劇種如先秦至唐代之 戲曲小戲 宋金雜劇院本 北曲雜劇四折每折作獨立性演出 乃至明清民間 小戲與南雜劇之一折短劇 均實為折子戲之 先驅 則明正德至嘉靖間北劇南 戲選本之 摘套 與 散齣 迎神賽社禮節傳簿 中之 零折散齣 均可 視之為

untitled

C 1

Java Access 5-1 Server Client Client Server Server Client 5-2 DataInputStream Class java.io.datainptstream (extends) FilterInputStream InputStream Obj

2011-论文选集-2.cdr

BOOL EnumWindows(WNDENUMPROC lparam); lpenumfunc, LPARAM (Native Interface) PowerBuilder PowerBuilder PBNI 2

51 C 51 isp 10 C PCB C C C C KEIL

Java java.lang.math Java Java.util.Random : ArithmeticException int zero = 0; try { int i= 72 / zero ; }catch (ArithmeticException e ) { // } 0,

untitled

C/C++ - 字符输入输出和字符确认

2013 C 1 # include <stdio.h> 2 int main ( void ) 3 { 4 int cases, a, b, i; 5 scanf ("%d", & cases ); 6 for (i = 0;i < cases ;i ++) 7 { 8 scanf ("%d %d

JavaIO.PDF

Visual Basic D 3D

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File

C

Chapter 9: Objects and Classes

第一章 章标题-F2 上空24,下空24

untitled

中華民國青溪協會第四屆第三次理監事聯席會議資料

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

untitled

Java

Microsoft Word - CPE考生使用手冊 docx

untitled

untitled

untitled

(HMI) IO A

《大话设计模式》第一章

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023)

nooog

untitled

C/C++ - 文件IO

Microsoft PowerPoint - L17_Inheritance_v4.pptx

C/C++语言 - 分支结构

Microsoft Office SharePoint Server MOSS Web SharePoint Web SharePoint 22 Web SharePoint Web Web SharePoint Web Web f Lists.asmx Web Web CAML f

エスポラージュ株式会社 住所 : 東京都江東区大島 東急ドエルアルス大島 HP: ******************* * 关于 Java 测试试题 ******

27 :OPC 45 [4] (Automation Interface Standard), (Costom Interface Standard), OPC 2,,, VB Delphi OPC, OPC C++, OPC OPC OPC, [1] 1 OPC 1.1 OPC OPC(OLE f

2 WF 1 T I P WF WF WF WF WF WF WF WF 2.1 WF WF WF WF WF WF

C++ 程式設計

Computer Architecture

新版 明解C言語入門編

C H A P T E R 7 Windows Vista Windows Vista Windows Vista FAT16 FAT32 NTFS NTFS New Technology File System NTFS

e 2 3 2

2015年计算机二级(C语言)模拟试题及答案(四)


zt

02

全国计算机技术与软件专业技术资格(水平)考试

PowerPoint Presentation

javaexample-02.pdf

untitled

<4D F736F F D20B2C43032B3B920B8EAAEC6ABACBA41BB50AAEDA5DCA6A12E646F63>


用户大会 论文集2.2.doc

untitled

TC35短信发送程序设计

Ps22Pdf

Strings


Python a p p l e b e a r c Fruit Animal a p p l e b e a r c 2-2

《米开朗琪罗传》

新・解きながら学ぶC言語

C

<4D F736F F D B0D3B77EC3FEA7DEC3C0C476C1C9A5BFA6A1B8D5C3442DB57BA6A1B35DAD702DBEC7ACEC2E646F6378>

(TestFailure) JUnit Framework AssertionFailedError JUnit Composite TestSuite Test TestSuite run() run() JUnit

zt

Ps22Pdf

Transcription:

1. 2. 3. 4. CHAPTER 2-1 2-2 2-3 2-4 VC# 2-5 2-6 2-7 2-8

Visual C# 2008 2-1 Visual C# 0~100 (-32768~+32767) 2 4 VC# (Overflow) 2-1 2-2

2-1 2-1.1 2-1 1 10 10!(1 10) 2-3

Visual C# 2008 10! 32767 short( ) int( ) 2-2 ch2-1_1.sln 2-2 01 03 04 05 06 07 08 09 10 private void Form1_Load(object sender, EventArgs e) { // int t; int total=1; //( short int) for (t = 1; t <= 10; t++) total = total * t; MessageBox.Show("10!=" + total.tostring() ); 2-1 short( 短整數 ) System.Int16 2Byte -32,768 至 32,767 int( 整數 ) System.Int32 4Byte -2,147,483,648 至 2,147,483,647 long( 長整數 ) System.Int64 8Byte -9,223,372,036,854,775,808 至 9,223,372,036,854,775,807 ushort( 無號短整數 ) System.Int16 2Byte 0 至 65,535 uint( 無號整數 ) System.Int32 4Byte 0 至 4,294,967,295 2-4

ulong( 無號長整數 ) System.Int64 8Byte 0 至 18,446,744,073,709,551,615 float( 浮點數 ) System.Single 4Byte 1.5 10-45 至 3.4 10 37 double( 雙精準度 ) System.Double 8Byte 5.0 10-324 至 1.7 10 308 decimal ( 貨幣 ) System.Decimal 16Byte 1.0 10-28 至 7.9 10 28 int a=10; System.Int32 a=10; 2-1.2 string( ) int 2-2 2-2 char( ) System.Char 2Bytes 0 65535 string( ) System.String User 1 2 31 string char c= 'A'; // string s = "A"; // 2-5

Visual C# 2008 2-3 Stu_Name=TextBox1.Text; Eng_Score = int.parse (TextBox3.Text); Chi_Score = int.parse (TextBox2.Text); 2-3 (int.parse ) ch2-1_2.sln 01 03 04 05 06 07 08 09 10 11 12 13 private void Button1_Click(object sender, EventArgs e) { string Stu_Name; int Chi_Score, Eng_Score, Average; Stu_Name = TextBox1.Text; Chi_Score = int.parse (TextBox2.Text); Eng_Score = int.parse (TextBox3.Text); Average = (Chi_Score + Eng_Score) / 2; MessageBox.Show(Stu_Name + " " + Average); 2-6

03~05 static void Main(string[] args) { // int a, b, c; char x, y; float z; int a, b, c; 3*4 byte=12 byte char x, y; 2*2 byte=4 byte float z; 1*4 byte=4 byte ' Backspace Enter escape sequence 2-3 2-3 '\n' (new line) string Str1 = "Visual"; string Str2 = "C#"; MessageBox.Show(Str1+ "\n" + Str2); 2-7

Visual C# 2008 \t (tab) string Str1 = "Visual"; string Str2 = "C#"; MessageBox.Show(Str1+ "\t" + Str2); \r (carriage return) string Str1 = " "; string Str2 = " "; MessageBox.Show(Str1+ "\r" + Str2); \\ string Str1 = "C:"; string Str2 = "Data"; MessageBox.Show(Str1+ "\\" + Str2); \ ' (single quote) string Str1 = "I"; string Str2 = "m a Ph.D. student"; MessageBox.Show(Str1+ "\'" + Str2); \ ' ' (double quote) string Str1 = "I\'m a "; string Str2 = "Ph.D.\" student"; MessageBox.Show(Str1+ "\"" + Str2); \x 16 ASCII string Str1 = " "; string Str2 = " "; MessageBox.Show(Str1+ "\x41" + Str2); 2-1.3 2-4 2-8

2-4 bool( 布林 ) System.Boolean 2Byte True(-1) 或 False(0) object( 物件 ) System.Object 8Byte (Boolean) True( ) False( ) 2-4 if(2>1) printf ("True"); else printf ("False"); 執行結果 2-4 2-2 (Variable) (Constant) A=B+1 1 A B 1 A B C# 2-2.2 2-9

Visual C# 2008 2-2.1 (Variable) 1 int A,B,C; A,B,C 2-5 A B C 2-5 2 2-6 2-10 2-6

VC# 2008 2-2.2 VC# 2008 1 =, 2 =, ; int R; float A; int A,B,C; // R // A // A,B,C 2-11

Visual C# 2008 1+2+ +10 ch2-2_2.sln 01 03 04 05 06 07 08 09 private void button1_click(object sender, EventArgs e) { int i, Sum; for (i = 1; i <= 10; i++) Sum = Sun + 1; MessageBox.Show(" " + Sum); VB ( ) 1 Sum = Sun + 1 Sum = Sum + 1 VC# ( ) Sun 2-12

2-2.3? (=) 01 int R; // 將變數 R 宣告為整數型態 float A; // 將變數 A 宣告為浮點數型態 03 R=5 // 指定 5 給 R 04 A=6.28 6.28 A 01 int R=5; float A=6.28; R 5 R A 6.28 A 2-2.4 Visual C# (Statement) ( ) a = 10; 2-13

Visual C# 2008 01 03 04 05 06 07 { int a, b, c; a = 10; b = 5; c = a + b; MessageBox.Show(c.ToString()); 2-2.5 Visual C# 1. (!, @, #, $, %, * ) 2-5 2. VC# 2008 1 3. 4. (a~z ) 5. ( ) 2-5 M2 正確 ( 英文字母開頭 ) 3M A*5 MessageBox MessageBox 是保留字 2-14

1 (Reserved Word) Visual C#2008 (Property) (Event) (Method) (Operator) (Function) for, loop, if 2-2.6 1. VC# 2008 TOTAL, Total total 2. VC# 2008 Stu_Name( ) Stu_No( ) 3. int Start_X; // X 2-2.7 (Constant) 3.14 3.14 3.14 3.141592 3.14 3.141592 2-15

Visual C# 2008 R = 3; A = 3.14 * (Math.Pow(R,2)); L = 2 * 3.14 * R; R = 3; A = 3.141593 * (Math.Pow(R,2)); L = 2 * 3.14 * R; ( 3.141592 3) ( ) const = ; const double PI=3.141592; // PI 3.141592 01 03 04 05 06 double R, A, L; const double PI=3.141592; //.14 R = 3; A = PI * (Math.Pow(R,2)); L = 2 * PI * R; MessageBox.Show(A.ToString()); PI Visual C# " const string MyName=" "; const string MyID="A123456789"; 2-16

1. 2. 3. 2-3 (60 61 ) 60 60.5 (Implicit Conversion) (Explicit Conversion) 2-3.1 (Implicit Conversion) ( int double) 2-17

Visual C# 2008 ch2-3_1.sln 01 03 04 05 06 07 08 09 10 11 12 13 14 15 16 namespace ch2_3_1 { class Program { static void Main(string args) { int score = 60; double c; c = score; Console.WriteLine(" {0", c); Console.ReadLine(); 2-18

2-3.2 (Explicit Conversion) ( double int) ( int float) int float ( double int) ch2-3_2.sln 2-19

Visual C# 2008 01 03 04 05 06 07 08 09 10 static void Main(string[ ] args) { double score = 60.5; int c; c =(int)score; Console.WriteLine(" {0", c); Console.ReadLine(); (int) (c) ( int float) ch2-3_2a.sln 2-20

01 03 04 05 06 07 08 09 10 static void Main(string[ ] args) { int i = 60, j = 61; float c; c = (i + j) / 2; Console.WriteLine(" {0", c); Console.ReadLine(); ch2-3_2b.sln 01 03 04 05 06 07 08 09 10 static void Main(string args) { int i = 60, j = 61; float c; c = (float)(i + j) / 2; Console.WriteLine(" {0", c); Console.ReadLine(); (float) (c) 2-21

Visual C# 2008 1 c 01 03 04 05 06 07 08 09 10 static void Main(string[ ] args) { int a=10,b=3; double c; c = a/b; Console.WriteLine("c={0",c); Console.ReadLine(); c=3 a/b int( 3) c c = a / b; double int int int 2 c 01 03 04 05 06 07 08 09 10 static void Main(string[ ] args) { int a=10,b=3; double c; c = (double)a / (double)b; Console.WriteLine("c={0",c); Console.ReadLine(); 2-22

c=3.33333333333333 a/b double c c =( double ) a / ( double ) b; double double double double 2-4 VC# /* */ 1. double R, A, L; R,A,L 2-23

Visual C# 2008 2. /* */ /* PI*R2 2*PI*R */ /* */ ch2-4.sln 01 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 private void button1_click(object sender, EventArgs e) { /* PI*R2 *PI*R */ double R, A, L; R,A,L const double PI = 3.141592; //.14 R = 3; A = PI * (Math.Pow(R, 2)); L = 2 * PI * R; MessageBox.Show(" =" + A.ToString()); MessageBox.Show(" =" + L.ToString()); 2-24

2-5 C# ➊ int i, j; int i, j; for (i = 1; i <= 9; i++) { for (j = 1; j <= 9; j++) { // ➋ for (i = 1; i <= 9; i++) { for (j = 1; j <= 9; j++) { // 2-6 --- --- (Expression) (Operand) (Operator) A=B+1 A,B,1 =,+ 2-25

Visual C# 2008 ( ) ( ) ( ) ( ) 2-7 A = PI * (Math.Pow(R, 2)); L = 2 * PI * R; = + + 2-7 2-6.1 VC# 2008 = (* 1) = A B Sum 10 Sum=0; 20 A=1; 30 B=2; 40 Sum=A+B; 1 VB = Sum 0 3 2-26

= 10 Sum=0; ( ) 20 A=1; ( ) 30 2=B; ( ) = 40 A+B=Sum; ( ) = 30 40 2-6.2 2-6 2-6 1 ++ ( ) -- ( ) a 1 a 1 a++ a-- 2 ( ) a b a*b 30 ( a=10,b=3) a= a +1 a = a -1 2 ( ) a b a/b 3.33333333. 2 % ( ) a b a % b 1 3 ( ) a b a+b 13 3 ( ) a b a-b 7 1 * 2-27

Visual C# 2008 2 (++) (--) (1) ++i ++ -- 1 1 A=10; B=++A; A=10; B=--A; A=11 B=11 A 1 B A=9 B=9 A 1 B (2) i++ ++ -- 1 1 A=10; B=A++; A=10; B=A--; A=11 B=10 A B A 1 A=9 B=10 A B A 1 3 %( ) a b a b VB Mod 2-28

1 ➊? (3+5)*2 ➋ Enter ➌ (3+5)*2 16 ➋ 再按 Enter ➊ 首先輸入? ➌ 系統會即時在下一行顯示結果 2-8 2 6+15/3*2-4 ➊ 15/3=5 ➋ 5*2=10 ➌ 6+10=16 ➍ 16-4=12 (6+15)/3*2-4 ➊ 6+15=21 ➋ 21/3=7 7*2=14 ➌ 14-4=10 2-29

Visual C# 2008 VC# (1) F=3A+2B+C (2) F= A X 2 + B X + C (3) F=( A) X Y + B Z +1 (4) F=( A + B)(C +D) (5) F= A X 2.5 + B X 1.5 + C X 0.5 (1) F=3*A+2*B+C (2) F=A* Math.Pow(X,2)+ Math.Pow(B,X)+C (3) F= Math.Pow(A,X*Y)+ Math.Pow(B,Z)+1 (4) F=(A+B)*(C+D) (5) F=A*Math.Pow(X,2.5)+B* Math.Pow(X,1.5)+C* Math.Pow(X,0.5) a,b 01 03 04 05 06 07 static void Main(string[ ] args) { int i=10; int a, b; a = i++; b = i--; ➊ a=10 ( i a 1) ➋ b=11 ( 05 i 11 06 i b 1) 2-30

a,b 01 03 04 05 06 07 static void Main(string[ ] args) { int i=10; int a, b; a = i++; b = ++i; (++) (--) ➊ a=10 ( i a 1) ➋ b=12 ( 05 i 11 06 ++ i i 1(i=12) b) 2-6.3, 1. True( ) False( ) 2-7 2-31