Introduction to Computer Science - PowerPoint PPT Presentation

About This Presentation
Title:

Introduction to Computer Science

Description:

/ / – PowerPoint PPT presentation

Number of Views:43
Avg rating:3.0/5.0
Slides: 47
Provided by: Shyh3
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Computer Science


1
????????
  • ???
  • ??????
  • ??????/???????/
  • ???????????

2
??
  1. ???????
  2. ??????
  3. ????????????
  4. ????
  5. ???????
  6. ????, ??if??, ?????
  7. bool????????
  8. ??????

3
??
  1. ???????
  2. ??????
  3. ????????????
  4. ????
  5. ???????
  6. ????, ??if??, ?????
  7. bool????????
  8. ??????

4
????UsingVariable????
  • char aChar 'a'
  • Console.WriteLine(aChar)
  • int anInt 123
  • Console.WriteLine(anInt)
  • double aDouble
  • aDouble 123.456
  • Console.WriteLine(aDouble)
  • bool aBool true
  • Console.WriteLine(aBool)

5
???????
J. G. Brookshear, Computer Science An
Overview, 8th edition, Addison-Wesley, 2005
6
????
  • ?????????
  • ????
  • ????????
  • ????
  • ????
  • ??????
  • ?? (Assignment) ???? (Initialization)
  • ????

7
????UsingNumeric????
  • int x 256
  • Console.WriteLine("x " x)
  • byte y 255
  • Console.WriteLine("y " y)
  • double z 123.45
  • Console.WriteLine("z " z)
  • float f 123.45f
  • Console.WriteLine("f " f)
  • decimal d 123.45m
  • Console.WriteLine("d " d)

8
????
  • sbyte -128 127
  • byte 0 255
  • short -32768 32767
  • unshort 0 65535
  • int -2147483648 2147483647
  • uint 0 4294967295
  • long -9223372036854775808 9223372036854775807
  • ulong 0 18446744073709551615
  • char U0000 Uffff

9
?????
  • float 7 ????, ??1.5e-45 3.4e38, 32 ??
  • double 1516????, ??5.0e-324 1.7e308, 64 ??

0
10
decimal ??
  • 28 29 ???, ??1.0e-28 7.9e28, 128 ??

11
????UsingChar????
  • char c1 'a'
  • char c2 '?'
  • char c3 '\x0059'
  • char c4 '\u0058'
  • char c5 '\n'
  • char c6 '\''

12
????
  • ASCII vs. Unicode
  • ?????Unicode???
  • ????( Escaped character )
  • \a ??(alarm)
  • \b ??(backspace)
  • \ ???(apostrophe)
  • \\ ???(backslash)
  • \t ????(tab)
  • \n ??(next line)

13
?????
  • string s1 abc
  • string s2 a
  • char c a

14
??(Stack)???(Heap)
. . .
Stack
15
????????
??(Stack)
int x 100
100
x
16
????????
??(Heap)
??(Stack)
string x abc
a
??
x
b
c
17
??
  • ?????,?????????,?????

18
??
  1. ???????
  2. ??????
  3. ????????????
  4. ????
  5. ???????
  6. ????, ??if??, ?????
  7. bool????????
  8. ??????

19
????Conversion????
  • int a 10
  • double b 0
  • b a
  • b 20.5
  • a (int)b
  • float c 20
  • c 20.5f
  • c (float)20.5
  • char d (char)65

20
?????????
  • ???? (Assignment)
  • ???? (Implicit conversion)
  • ???? (Explicit conversion)

21
??
  1. ???????
  2. ??????
  3. ????????????
  4. ????
  5. ???????
  6. ????, ??if??, ?????
  7. bool????????
  8. ??????

22
????UsingMathOperator????
  • Console.WriteLine("?????????x ")
  • int x int.Parse(Console.ReadLine())
  • Console.WriteLine("?????????y ")
  • int y int.Parse(Console.ReadLine())
  • Console.WriteLine(" x y 0 ", x y)
  • Console.WriteLine(" x - y 0 ", x - y)
  • Console.WriteLine(" x y 0 ", x y)
  • Console.WriteLine(" x / y 0 ", x / y)
  • Console.WriteLine(" x y 0 ", x y)

23
???????
  • ???(Operand)????(Operator)
  • ?????(Assignment)
  • ?????
  • ???????
  • ??
  • ?????????

24
????????
  • ?1
  • byte bValue 254
  • bValue bValue2
  • ?2
  • byte bValue
  • int aa 0
  • bValue aa 0
  • ?3
  • float f 0
  • f 0.1 0.1

25
????UsingMathFunctions????
  • Console.WriteLine("Sqrt(2) " Math.Sqrt(2.0))
  • Console.WriteLine("PI " Math.PI)
  • Console.WriteLine("Sin(PI/6.0) "
    Math.Sin(Math.PI / 6.0))
  • Console.WriteLine("Pow(2.0, 0.5) "
    Math.Pow(2.0, 0.5))
  • Console.WriteLine("Exp(1) " Math.Exp(1.0))
  • Console.WriteLine("ln(e) " Math.Log(Math.E))
  • Console.WriteLine("log10(100) "
    Math.Log10(100.0))

26
??
  1. ???????
  2. ??????
  3. ????????????
  4. ????
  5. ???????
  6. ????, ??if??, ?????
  7. bool????????
  8. ??????

27
????UsingConstant????
  • int anInt 123
  • const int A_CONST 456
  • anInt 321

28
????
  • ????
  • ????
  • ???????

29
??
  1. ???????
  2. ??????
  3. ????????????
  4. ????
  5. ???????
  6. ????, ??if??, ?????
  7. bool????????
  8. ??????

30
????UsingInDeOperator????
  • Console.WriteLine("???????x??")
  • int x0 int.Parse(Console.ReadLine())
  • Console.WriteLine("???????????add")
  • int add int.Parse(Console.ReadLine())
  • int x x0
  • x x add
  • x x0
  • x add
  • int post
  • x x0
  • post x
  • int pre
  • x x0
  • pre x

31
???????
  • ??? ?-??/-?
  • ????--
  • ?????(prefix)
  • result x
  • ?????(postfix)
  • result x

32
??
  1. ???????
  2. ??????
  3. ????????????
  4. ????
  5. ???????
  6. ????, ??if??, ?????
  7. bool????????
  8. ??????

33
??(Relation)???
??? ?? ??? ??
?? ! ???
gt ?? gt ????
lt ?? lt ????
34
if ??
score lt 60
false
true
score 60
35
????UsingSimpleIf????
  • Console.Write(
  • "???????100??????? ")
  • int score int.Parse(Console.ReadLine())
  • // ????
  • if (score lt 60)
  • score 60
  • Console.WriteLine("????? " score)

36
if-else ??
score lt 60
true
false
result score
result 60
37
????UsingTerOp????
  • Console.Write(
  • "???????100??????? ")
  • int score int.Parse(Console.ReadLine())
  • int result score lt 60 ? 60 score
  • // ????
  • Console.WriteLine("????? " result)

38
??
  1. ???????
  2. ??????
  3. ????????????
  4. ????
  5. ???????
  6. ????, ??if??, ?????
  7. bool????????
  8. ??????

39
????UsingLB????
  • bool x 7 gt 3
  • bool y 2 lt 0
  • bool xORy x y
  • bool xANDy x y
  • bool xOy (x y) (x y)
  • bool xNy (x y) (x y)

40
????
  • ????, ????, Debug.Assert()
  • x gt 1
  • true/false, ???????1 ? 0

41
??????
x y x y x y x y !y
false false false false false true
true false false true true true
false true false true true false
true true true true false false
42
Short-Circuit ????
  • ?
  • ??
  • x y
  • x y
  • (x y) (x y)
  • (x y) (x y)

43
??????
  • string first one
  • string second One
  • string third one
  • Console.WriteLine( first second )
  • Console.WriteLine( first third )
  • Console.WriteLine( first ! second )
  • Console.WriteLine( first ! third )

44
??
  1. ???????
  2. ??????
  3. ????????????
  4. ????
  5. ???????
  6. ????, ??if??, ?????
  7. bool????????
  8. ??????

45
???????
  • ????????
  • ?????????
  • ???
  • ?????????
  • ?????
  • ????? !, , , , ,
  • ?????
  • ?? ,,/,,,-,,,
  • ????????

46
??
  • ??????????????, ??????????,??,??,?????
Write a Comment
User Comments (0)
About PowerShow.com