nooog



Similar documents
新版 明解C言語入門編

FY.DOC

CC213

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

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

新・明解C言語入門編『索引』

C/C++ - 文件IO

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

C/C++ - 函数

C

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

,,,,,,,,,, ( http: \ \ www. ncre. cn,, ) 30,,,,,,,, C : C : : 19 : : : /16 : : 96 : : : ISBN 7

C/C++ 语言 - 循环

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

Ps22Pdf

C/C++ - 字符串与字符串函数

Ps22Pdf

CC213

_汪_文前新ok[3.1].doc

untitled

C 1

Microsoft Word - 第3章.doc

untitled

プログラムの設計と実現II

3.1 num = 3 ch = 'C' 2

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit

untitled

CC213

新版 明解C++入門編

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

C C

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

untitled

C/C++ - 数组与指针

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

四川省普通高等学校

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


Microsoft Word - CPE考生使用手冊 docx

上海市本科教学质量年度报告

untitled

科学计算的语言-FORTRAN95

untitled

untitled

c_cpp

C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C Project 30 C Project 3 60 Project 40

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

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++;

C

C/C++ - 结构体、共用体、枚举体

untitled

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

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

untitled

新・解きながら学ぶJava

《C语言程序设计》教材习题参考答案

Microsoft Word 年9月二级C真卷.doc

C PICC C++ C++ C C #include<pic.h> C static volatile unsigned char 0x01; static volatile unsigned char 0x02; static volatile unsigned cha

第5章修改稿

chap07.key

CHAPTER VC#

epub 33-8

untitled

C

VB程序设计教程

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

Microsoft Word - chap13.doc

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

概述

内 容 提 要 指 针 持 久 动 态 内 存 分 配 字 符 串 ( 字 符 数 组 ) 2

Microsoft PowerPoint - OPVB1基本VB.ppt

02

Microsoft PowerPoint - ds-1.ppt [兼容模式]

(\244j\257d\276\307\274\351_ C.indd_70%.pdf)

Microsoft Word 軟體設計第二部份範例試題_C++_ _1_.doc

C语言的应用.PDF

1 LINUX IDE Emacs gcc gdb Emacs + gcc + gdb IDE Emacs IDE C Emacs Emacs IDE ICE Integrated Computing Environment Emacs Unix Linux Emacs Emacs Emacs Un

untitled

untitled

Microsoft Word - 01.DOC

Chapter12 Derived Classes

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc

3A 吳嘉詠

Microsoft PowerPoint - C_Structure.ppt

Windows RTEMS 1 Danilliu MMI TCP/IP QEMU i386 QEMU ARM POWERPC i386 IPC PC104 uc/os-ii uc/os MMI TCP/IP i386 PORT Linux ecos Linux ecos ecos eco

( ) : ( ) (CIP) /.. :,003. () ISBN O4 44 CIP (00) : : 7 : 7007 : (09 ) : : :850 mm 68 mm / 3 :0.5 :60 :00 0

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

导 生 和 被 辅 导 成 员 在 辅 导 过 程 中 的 一 些 不 足 与 可 取 点, 经 过 25 分 钟 的 讨 论, 各 小 组 派 代 表 阐 述 了 各 方 观 点 和 改 进 方 法 然 后, 为 了 改 善 导 生 辅 导 方 法, 让 辅 导 变 得 更 有 效 率, 各 院

华恒家庭网关方案

高 职 计 算 机 类 优 秀 教 材 书 目 * 序 号 书 号 (ISBN) 书 名 作 者 定 价 出 版 / 印 刷 日 期 ** 配 套 资 源 页 码 计 算 机 基 础 课 计 算 机 应 用 基 础 刘 升 贵 年 8 月

该 奈 自 受 PZ 多 透 soc i e B t h y. y t is NA YL OR exp os ed t h a t b e i n g wh o res or sa in t es s e s we r e m ad e n b ot om. M ean wh i l e NA YL

<4D F736F F D D342DA57CA7DEA447B14D2DA475B57BBB50BADEB27AC3FEB14DA447B8D5C344>

, 7, Windows,,,, : ,,,, ;,, ( CIP) /,,. : ;, ( 21 ) ISBN : -. TP CIP ( 2005) 1

WWW PHP

数据结构与算法 - Python基础

epub83-1

ebook8-30

碩命題橫式

数 学 高 分 的 展 望 一 管 理 类 联 考 分 析 第 一 篇 大 纲 解 析 篇 编 写 : 孙 华 明 1 综 合 能 力 考 试 时 间 :014 年 1 月 4 日 上 午 8:30~11:30 分 值 分 配 : 数 学 :75 分 逻 辑 :60 分 作 文 :65 分 ; 总

3. 給 定 一 整 數 陣 列 a[0] a[1] a[99] 且 a[k]=3k+1, 以 value=100 呼 叫 以 下 兩 函 式, 假 設 函 式 f1 及 f2 之 while 迴 圈 主 體 分 別 執 行 n1 與 n2 次 (i.e, 計 算 if 敘 述 執 行 次 數, 不

Transcription:

C : : :

, C C,,, C, C,, C ( ), ( ) C,,, ;,, ; C,,, ;, ;, ;, ;,,,, ;,,, ; : 1 9, 2 3, 4, 5, 6 10 11, 7 8, 12 13,,,,, 2008 1

1 (1 ) 1.1 (1 ) 1.1.1 ( ) 1.1.2 ( ) 1.1.3 ( ) 1.1.4 ( ) 1.1.5 ( ) 1.2 ( ) 1.2.1 ( ) 1.2.2 ( ) 1.2.3 ( ) 1.2.4 ( ) 1.2.5 ( ) 1 ( ) 2 C ( ) 2.1 C ( ) 2.2.1 C ( ) 2.2.2 C ( ) 2.2 C ( ) 2.3 C ( ) 2.4 C ( ) 2.4.1 C ( ) 2.4.2 C VC + + 6 0 ( )

2 ( ) 3 ( ) 3.1 C ( ) 3.1.1 ( ) 3.1.2 ( ) 3.2 ( ) 3.2.1 ( ) 3.2.2 ( ) 3.3 ( ) 3.3.1 ( ) 3.3.2 ( ) 3.4 ( ) 3.4.1 ( ) 3.4.2 ( ) 3.5 ( ) 3.5.1 ( ) 3.5.2 ( ) 3.6 ( ) 3.6.1 ( ) 3.6.2 ( ) 3.6.3 ( ) 3.6.4 ( ) 3.6.5 ( ) 3.7 ( ) 3.7.1 ( ) 3.7.2 ( ) 3 ( ) 4 ( ) 4.1 ( ) 4.1.1 C ( ) 4.1.2 C ( ) 4.2 ( )

4.2.1 ( ) 4.2.2 ( ) 4.3 ( ) 4.3.1 getchar ( ) 4.3.2 putchar ( ) 4.3.3 gets ( ) 4.3.4 puts ( ) 4 ( ) 5 ( ) 5.1 ( ) 5.2 ( ) 5.3 ( ) 5.3.1 if ( ) 5.3.2 switch ( ) 5.4 ( ) 5.4.1 while ( ) 5.4.2 do - while ( ) 5.4.3 for ( ) 5.4.4 3 ( ) 5.4.5 ( ) 5.5 ( ) 5.5.1 break ( ) 5.5.2 continue ( ) 5.6 ( ) 5 ( ) 6 ( ) 6.1 ( ) 6.1.1 ( ) 6.1.2 ( ) 6.2 ( ) 6.3 ( ) 6.4 ( )

6 ( ) 7 ( ) 7.1 ( ) 7.1.1 ( ) 7.1.2 ( ) 7.2 ( ) 7.2.1 ( ) 7.2.2 ( ) 7.2.3 ( ) 7.3 ( ) 7.3.1 ( ) 7.3.2 ( ) 7.4 ( ) 7.4.1 ( ) 7.4.2 ( ) 7.5 ( ) 7.5.1 ( ) 7.5.2 ( ) 7.5.3 ( ) 7.5.4 ( ) 7.6 ( ) 7 ( ) 8 ( ) 8.1 ( ) 8.2.1 ( ) 8.2.2 ( ) 8.2.3 ( ) 8.2 ( ) 8.2.1 ( ) 8.2.2 ( ) 8.3 ( ) 8.3.1 ( )

8.3.2 ( ) 8.3.3 ( ) 8.3.4 ( ) 8.3.5 ( ) 8.4 ( ) 8.4.1 ( ) 8.4.2 ( ) 8.4.3 ( ) 8.5 main ( ) 8.6 ( ) 8 ( ) 9 C ( ) 9.1 ( ) 9.1.1 ( ) 9.1.2 ( ) 9.1.3 ( ) 9.2 ( ) 9.2.1 ( ) 9.2.2 ( ) 9.3 ( ) 9.4 ( ) 9 ( ) 10 ( ) 10.1 ( ) 10.1.1 ( ) 10.1.2 ( ) 10.1.3 ( ) 10.1.4 ( ) 10.2 ( ) 10.2.1 ( ) 10.2.2 ( ) 10.3 ( )

10.4 ( ) 10.5 ( ) 10.6 ( ) 10 ( ) 11 ( ) 11.1 ( ) 11.2 ( ) 11.2.1 ( ) 11.2.2 ( ) 11.3 ( ) 11.3.1 ( ) 11.3.2 ( ) 11.4 ( ) 11 ( ) 12 ( ) 12.1 C ( ) 12.2 ( ) 12.2.1 fopen ( ) 12.2.2 fclose ( ) 12.3 ( ) 12.3.1 ( ) 12.3.2 ( ) 12.3.3 ( ) 12.3.4 ( ) 12.4 ( ) 12.5 ( ) 12.6 ( ) 12 ( ) 13 C + + ( ) 13.1 ( )

13.2 C + + ( ) 13.2.1 C + + ( ) 13.2.2 C + + ( ) 13.2.3 C + + ( ) 13.2.4 C + + ( ) 13 ( ) 1 ( ) 2 ASCII ( ) 3 C VC + + 6 0 ( ) 4 ( ) 5 C ( ) ( )

1 N - S :, : N - S, 1.1 1.1.1??,,,,,, ( ),,,,,,,,,,,,, : 10,,,

,2 3 8 9,, ( Algorithm) 9 al - k hovarizmi,,,,,,,,,,, 1.1.2,,,,,,,, :,,,,,,,, : 07 68,,, 1,, 1h A B,, 10h,,,,,,,,,,,,,,,,,,, : x = 1, y = 0, z = x/ y;,, z = x/ y,,, 99 98, 99 98,,,, : (1 ),,,,, :,,,

,,,,,, (2 ),,,,,,,, :,,,, (3 ),,,,,,, 1.1.3,,,, (1 ),,,,,, : 1.1 3 + 13, :,,,,, : 1 : 3 x, 13 y ; 2 : x + y, z ; 3 : z 1.2 100, 7,,,, : 1 :100 y, 7 x; 2 : y x, 3 ; 3 4 ; 3 :, 5 ; 4 : ; 5 :,,,,, ;,,,,

,,,,,,,, 100 7,,,,,, ( :?) : 1 :7 x, 100 y; 2 : y% x = 0? 0 3 ; 3 4 ; 3 :, 5 ; 4 : ; 5 : (2 ) ( ) ( ) ( ),,,,,,,,,,,, N - S 1.1 1.2 1.1 1.2 (3 ) N - S,,, (, ) ( ),,,,,, ( ), 1.2, ( A B ),, A, B,,

,,, ( 1.3 ) ( 1.4 ) ( 1.5 1.6) 1.3,,, C A B, A, B, A, B,,,,, 1.4, A, 1.5 1.6 1.5, C1,, A1 An + 1, C1,, C1 C2 Cn, An + 1, An + 1 1.6 1.5,, 1.6, C1 C2 Cn, 1 2 1 3 1 4 1 5 ( ) 1 6 ( ),,,,, 1.7 1.8 1.9 1.7,, C,, A( A, A ), A,, A, A C, C,, ( B ) 1.8,, A( A ), A( ),, A, A C,

C,, ( B ) 1.9 1.8,, C A, C,, ( B ) 1 7 ( ) 1 8 ( ) 1 9 ( ) :, : 1.7,,,, C, 1.8 1.9,, C,,,, 1.2 1.3 A B, 1.4 A, 1.5 A1 A2 An An + 1, 1.6 A1 A2 An, 1.7 1.9 A B,,,,,,,,,,,,, : ; ; ; ( ), I.Nassi B.Shneiderman,, N - S, N - S N - S N - S,,, ( ),, N - S, 1.10 1.15, 1.2 1.9, N - S,

1 10 1 11 ( ) 1 12 ( ) 1 13 ( ) 1 14 ( ) 1 15 ( ) 1.3 N - S x : x,,,,, -x, x, x, N - S 1.16, 1.17 1 16 N - S 1 17, : 1 : x ; 2 : x 0, x, 4 ; 3 : -x; 4 : (4 ),, ( ),,,,, 1.3 : x if x > = 0 x x : x

x : x if x is positive then print x else print x x x 1.1.4 1,?,,,,,,,,,,!,,,,,,!,,,,!, :,! 2?, :,,, :,,,,,,,,, x, y,,,,,,, 3,,, : 07 918, x y, ( 6 ),,, = +,,,

,, 1.1.5,,,,, :,,,,,,,, 10min,, 0.1s,,,,,,,,,,,,,,,, ;, ( ), 1.2 1.2.1,,, ( ) ( ),,,,,,,,,,,,,,, 1.2.2,, : C C + + Java BASIC Fortran Pascal Cobol ;,, : 1,,,,, 0 1,

,,,,, 2,,,,, ( ),,, ( ), 3,,,, C BASIC Pascal Fortran, ( ),, 4,,,,, : Excel PowerBuilder FoxP ro - 4GL, C + + 5,,, C, C ( C ), C, C, 1.2.3, :,,,,,,,,,,,,,,,,,, 1.2.4,,,,,,,, ( 1.1.4 ),,,,,,,,,,,

,,,, 1.2.5, 3 ( ),,,,,,, ( 9 ),,,, 3, C, C, C,, C, C, C,,,,,,,,,, 1 1 a, b, c,, 2 a, b, c,,

2 C C C C C : C, C, C : C 2.1 C 2.1.1 C C 20 70 1978 ( A T & T ) C B.W.Kernighan D.M.Ritchit T HE C PROGRAMMING LA NG UA GE K & R, K & R, K & R C, C, 1983, ANSI C 2.1.2 C C,, C,,, ( bit) C, C,,, C,, C C U NIX C

, 20 80, C,, 2.2 C, C, ( A Z, a z) (0 9 ) _, : zz, x1, _5y, temp1, mum8 : 6s x T ( : ) ( : ) - 6x ( : ) zhue - 1 ( : - ) C : 1. : C, C (1 ) :, int double (2 ) :, if else for C,, 32, 3.1 3.1 au to double int struct break else long switc h case e nu m r egister typedef cha r ex tern ret urn union con tinu e float shor t unsigned const for signed void default got o sizeof volatile do if static while 2., define C,,, 3.,

, ;,,,, : C, C, C,, C, BOO K book,,, 2.3 C C,, C C 2.1 {printf( I am a Student! \ n ) ; : main, C ( main ) printf C, I am a Student! \ n I am a Student!, C 2.2 # include stdio.h # include math.h / / { double x, y; / / x, y printf( input number: \ n ) ; scanf( % lf, & x ) ; / / x y = cos ( x) ; / / x, y printf( cos of % lf is % lf\ n, x, y) ; / / : x, x main, include

11 ), < > ( / / / /,, 4 x y 6 x, 7 x, y 8 % lf x y 2.3 # include stdio.h int min (int x, int y) ; { int m, n, r; / / scanf( % d, % d, & m, & n ) ; / / m n r = min ( m, n ) ; printf( min = %d, r) ; / / r int min (int x, int y) / / min, r / / min,,x y { int z; / / min z : if( x > y) z = y; else z = x; return(z) ; / / x y z : main min / / min, z min : x y z return z main main scanf, m n & m & n & %d, % d : main 3 min, m n min x y, min, r 3, C : C C C main,,,, printf scanf,, 2.3 min C C,, C main, C main (include ),

,, C, C / / / /, / /,, /, /, / /, / / 2.4 C 2.4.1 C C C C C,, C C.c.cpp C,.obj ( ),,, scanf printf,,,,.exe,.exe C 2.1 2.1 C 2.4.2 C VC + + 6.0 Vis ual C + + 6.0 Windows, Visual Basic Visual Foxpro Visual J + + Visual Studio ( Developer Studio) Developer Studio,, Developer Studio, VC + + 6.0 C 1.VC + + 6.0 (1 ) VC + + 6.0 :

Microsoft Visual Studio 6.0 Microsoft Vis ual C + + 6.0 Visual C + + 6.0 VC + + 6.0, 2.2, 2.2 VC + + (2 ),, (3 ) VC + + File Exit 2.2, VC + + 6.0 2. C (1 ) C File N ew ( : ^N ) 2.3 Files, 2.3 File C (.c,.cpp, ), Loca tion 2.3 C + + Source File, OK, VC + +, C,, File Save ( ^S ) C 2.3 C (2 ) C C,

File Open ( :^O) 2.4, C, VC + +,, 3. C 2.4 C 2.2 Build Compile, 2.5, 2.5,, 2.6 ( xxx C ) : xxx.obj - 0 error ( s ), 0 warning ( s) ( warning), (error ), 2.6,, VC + +, C,, 2.6

2.2 Build Build ( F7 ),,, ( xxx C ) : xxx.exe - 0 error ( s ), 0 w arning ( s) (error),, VC + +, C, ( ), 4. 2.2 Build! Execute ( ^F5 ).exe, VC + + 2.7, ( ) ( : C,!) ( ), VC + +,, 5. VC + + 6.0, C,,, C, ; 2.2 File Close Workspace 2.8,, 2.7 2.8 2.2, C, C,, C,, C C,,

1. A. C B. C C. C D. C, 2.C A. B. C. D. 3. A. C B. { C. C, D. C, 4. A. C B. C C. C D. C 5. A. C B. C main C. C, D. C 1., C 2.C,? 2

3,, :,,, : 3.1 C 3.1.1 C,, 3.1 (int) (float) ( double) (char) (void) (array) ( struct) ( union) (enum) 3 1

3.1.2 1, 2,, C : 3,, 4,,, 2.3 min, : int min(int x, int y ) int 2.2, cos,, y,,, void ( 7 ), 3.2 3.2.1, C (int ) ( float) (char ),,, : 35 0-89;, : 8.75-56.421 0.0;, : g 1 C,,, : # define # define ( #, 11 ),,,, PI 3.1 s # include < stdio.h > # define PI 3.14159

{ float s, r; r = 5; s = P I 3.2.2 r r; printf( s = % f\ n, s ) ;,,, C, C : ( ) : ;,,, 3.3 3.3.1 C 1,, 0 9, 237-568 65535 023( : 0 ) 23D( : D ) 2 0, 0, 0 7 : 015( 13 ) 0101( 65) 0177777( 65535) : 256( : 0 ) 03A2( : A )

3 0X 0x, 0 9, A F a f : 0X2A( 42) 0XA0 ( 160 ) 0XF FFF ( 65535) : 5A ( : 0X) 0X3 H ( : H), 3.3.2 1 : int, 4, : short int short, 2, : long int long, 4, : unsigned : un signed int un signed; un signed s hort ; un signed long, VC + +, 3.1 ASCII [ signed] int - 2147483648 2147483647-2 31 (2 31-1) 4 [ signed] short [int] - 32768 32767-2 15 (2 15-1) 2 [ signed] long [int] - 2147483648 2147483647-2 31 (2 31-1) 4 unsigned [int] 0 4294967295 0 (2 32-1 ) 4 unsigned short [ int] 0 65535 0 (2 16-1 ) 2 unsigned long [ int] 0 4294967295 0 (2 32-1 ) 4 C, L l : 325L ( 325), 045L ( 37), 0X18L ( 24 ), U u : 453u, 0x67Au, 872Lu 0XB5Lu B5, 181, 0, - 369 u 2 :,,...;

3.2 # include < stdio.h > { int a = 1, b = 2, c; / a b c, a b 1 2 / long x = 29, y = 2147483600; c = a ; a = 10; / a c / / a 10 / printf( \ na + b = % d, x + y = % ld, c = % d\ n, a + b, x + y, c) ; : a + b = 12, x + y = 2147483629, c = 1, :,, ;,, c = a; long x = 29, y = 2147483600;, 3.4 C,, : 3.4.1 1, 0 9 ( ) : 0.0, 123.,. 123, 12.3, 123.0, - 123.0 2, e E (, ) 3.14159 0.314159e1, 3.14159E0, 314.159e - 2 : a E n ( a, n, a 10 n ) : : E3( : E ) 36. - E6( : ) 4.2E( : ) 3.4.2 ( float ) ( double) ( long double),, A NSI C

, float 4, double 8 7 8, 15 16, 3.3 # include < stdio.h > { float x = 101235342.98345678; double y = 422222222345.11223344556677889900; printf( x = % f, y = % lf\ n, x, y) ; : x = 101235344.000000, y = 422222222345.112240 : x float, 8, 7 3.5 3.5.1, x,? : (1 ), (2 ), (3 ), 6 6, 6 + 2 8, 6 + 2 8, 56, 6,,, ASCII, 6 ASCII 54, 6 + 2 56 C, \,,,,,, printf \ n,, 3.2 C, \,,, \ \ \ \,, H appy birthday!, printf( \ H appy birthday! \ ) ;

3.2 \ n ( ) \ t \ b ( ) \ f ( ) \ r \ \ ( \ ) \ \ ( ) ( ) \ xhh 1 2 \ ddd 1 3 3.4 # include < stdio.h > { int x = 16, y = 2008; printf( y = % d\ rx = % d\ n, y, x ) ; printf( % c% c% c \ b%.1f\ n, C, +, +, 6.0) ; : x = 1608 C + 6.0 y = 2008 \ r,, x = x 16, x = 16,, y = 20, \ n,, C + +, \ b,, 6.0,, C + + + 3.5.2, char ASCII x ASCII 120 a x, a 120 :01111000,, C,,,,,,, 3.5

# include < stdio.h > { char a = 66 ; int b = A ; printf( a = % d( % c), b = % d( % c), a + 3 = % c, b 10 = % d\ n, a, a, b, b, a + 3, b 10 ) ; : a = 66 ( B), b = 65 ( A), a + 3 = E, b 10 = 650, a 66, ; A b, ; a 3, b 10 3.6 # include < stdio.h > { char a = x, b = Y ; / a, b / a = a - 32; / / b = b + 32 ; printf( % c, % c\ n, a, b) ; : X, y, a, b,, ASCII ASCII 32,, 3.6,, ;, : x + y - z/ 2 C C : 3.6.1 1 C ( + ) ( - ) ( ) (/ ) ( %, ) ( + + ) ( - - ) 7, (1 ) + a + b, 4 + 8 ( )

(2 ) -, -,, ( ), - x, - 5 (3 ), (4 ) /,,,,,,,,, 3.2 C, 0, (5 ) ( ) % 3 2,,, VC + +, : 16 % - 3 1, - 32 %5-2 3.7 # include < stdio.h > { printf( %d, % f\ n, 15/ 6, 15.0/ 6 ) ; printf( %d, % d, % d, % d\ n,100 %3, - 100%3,100 % - 3, - 100% - 3 ) ; : 2, 2.500000 1, - 1, 1, - 1,15 6, 15/ 6 ( ) 15.0/ 6, 15.0, (6 ) ( + + ) ( - - ) C,, ( + + ) ( - - ) : + + : 1 : + + x ; x = x + 1; - - : 1 : - - x; x = x - 1; + + - -, ( ), ( ) : x = x + 1; + + x; x + + ; + + x( - - x ), : x 1 ( 1 ), x x + + ( x - - ), : x, x 1 ( 1) + + ( - - ), 1 ( 1 ), 1( 1 ), C,

3.8 # include < stdio.h > { int x1 = 10, x2 = 10, y1, y2; printf( \ nx1 = %d, x2 = % d\ n, x1, x2) ; y1 = + + x1; y2 = x2 + + ; printf( y1 = %d, x1 = % d \ n, y1, x1 ) ; printf( y2 = %d, x2 = % d \ n, y2, x2 ) ; : x1 = 10, x2 = 10 y1 = 11, x1 = 11 y2 = 10, x2 = 11, y1 = + + x1;, x1 11, ( 11 ) y1; y2 = x2 + + ;, x2 ( : x2 10 y2), x2 11 2 C, 15 1, 15,, C, ( ) ( ), x - y + z, y -, x - y, + z, x = y = z, =, y = z x = ( y = z) (1 ) : ( ) ; +, - ( ) ;,/ ; +, - ( ) + ( ) - ( ), (2 ), :,, ;,,, 3 : ( ) ( )

( float)a a (int) ( x + y ) : x + y : (, ), : int( x + y),, ( int ) ( x + y ) (int) x + y, x int y,, 3.9 # include < stdio.h > { float f = 9.68; printf( (int)f = % d, f = % f\ n, (int) f, f) ; : (int) f = 9, f = 9.280000,, f f ( : ), : (int) f, 9( ) f 9.68, float 3.6.2 C : > ( ) > = ( ) < ( ) < = ( ) = = ( )! = ( ) ; : & & ( ) ( )! ( ) ( true) ( flase), true 0, flase 0 : 6 > 8 0, 12 > = 5 1, 1 + 8 = = 9 1, 10!= 10 + 10 1,!( 4 5 ) = = 0 1,2 & & 8 = = 1 1, 0 9 = = 0 0 :! > > = < < = = =! = & &! ( ) :, : int a = 75; printf( " a = % d", a > 60 ) ; 1,, : 0,,, 0;,

1, x = 23, y = 20, z = 10;, x > y > z, C, x y, z 1, x > y > z 0( 1 ), x > y & & y > z 1 3.10 # include < stdio.h > { int x = 6, y = 4, z = 2, v, w ; v = x - - y; w = ( y - 4 ) & & ( + + x + 1 ) ; printf( v = % d, y = % d, x = % d, w = % d\ n, v, y, x, w) ; : v = 1, y = 4, x = 6, w = 0, x = 6, v 1 (, - - y ), y 4 y - 4 0, w 0 (, + + x + 1 ), x 6 3.6.3 1 =, : = :,, : :, : x = 12, y = x + 25, y = func( ) =, : C x = x + 1, x 1, x, x = x + 1,, :, C =, :,, : x = y = z = 10 + 6 :, x = y = z = (10 + 6 ), ( ) : x = ( y = (z = (10 + 6 ) ) ), x = ( y = (z = 10 + 6 ) ), :

16 z = 10 + 6: 10 + 6, 16 z, z 16, ( z = 10 + 6 ) y = (z = 10 + 6 ) : (z = 10 + 6 ) 16 y, y 16, ( y = (z = 10 + 6) ) 16 ;, x, y, z 16,,, 2, = ;,,, : = ;, x = x + y; x + = y;, x = x ( y + z) ; x = y + z;, + = = C, C 10 : + = ( ), - = ( ), = ( ),/ = ( ), % = ( ), & = ( ), = ( ),^ = ( ), < < = ( ), > > = ( ) 3.11 # include < stdio.h > { int a = 0, b = 3, c = 1 ; a + = (a = 2) ; printf( %d, % d\ n, a, b + = b - = b b) ; printf( %d, % d\ n, c = - - b + 2, c = 9) ; : 4, - 12-99,9, printf printf,,, VC + + 6.0,, c = 9 (, c 1, c 9 ), 9, c = - - b + 2, c = c ( - - b + 2 ) = 9 ( - 13 + 2) = - 99, printf, : 4, - 12-11,9 3.6.4 1?: C?,, :

1?: 2: 3 : 1,, 2, 1, 3,, x = ( a > b)? a : b a b y = ( x > = 0)? x: - x x 2,,,, : 1, 2, 3,, n, : 1, 2,...... n, n : a = 8 2, a 4 ; / 64, a 16 / (a = 8 2, a 4), a 2; / 128, a 16 / a = ( b = 5,5 2) ; a = b = 5, 5 2 ; /, 10, b 5 / /, 10, a b 5 /,,, 3.6.5,, 1,, : char ch = d ; int i = 6; float f = 10.0; double d = 0.2, result ; Result = (ch/ i) + (4 + f d ) ( f - i) ; 40.0 2, 3.6.1 :,,, int a ; long int b = 1.45645878454566E2 ; a = ( int) b;, a 145 ( ), int a; long int b = ( int ) 1.45645878454566E10; a = ( int ) b ;, a

1679685957,,,,,, b, : 3.7 3.7.1 C 4 : & ( ) ( ) ^( ) ( ) C : < < > > (1 ) ( : ) : < < > > & ^ (2 ) 3 5 3.5 x y x &y x y x^y x 0 0 0 0 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 0 & : 1, 1, 0 0,, a = 10110110, a & 0 00000000, : 0, 0; a & a 10110110, :, ; a & 0x0f 00000110, : a 4 0, 4 : 0, 0, 1 1 : a = 10110110, a 0 10110110, : 0, ; a a 10110110, :, ; a 0x0f 10111111, : a 4, 4 1 ^

3.7.2 :, 0, 1, : a = 10110110, a^0 10110110, : 0, ; a^a 00000000, :, 0; a^0x0f 10111001, : a 4, 4 :, :0 1,1 0 : a = 10110110, a 01001001 < < > > : : 1 > > 2 1 < < 2 ( : ) ( : ) 1, 2,, 0, 1,, 1, 0; 1, 1 0, 0,, 1, 3.12 x 4 7 { un signed int x, y, z ; scanf( % x, & x) ; / / x y = x > > 3 ; z = y & 0x0f; printf( x = % x, z = % x \ n, x, z) ; / / 3, 4 7, y : (, 5a) x = 5a, z = b / / y 0x0f( 4 0, 4 1 ) C,,,,,,, 1 1 1 1 1.0

1. 4, A. _main enclude sin B. If - max turbo C. txt REAL 3COM D. int k_2 _001 2., A. _1234_ B. _1_2 C. int_2_ D. 2_int_ 3. C A. 10101110B B. 0386 C. 0Xffa D. 0x2H 3 4. A. 5E2.0 B. E - 3 C..2E0 D. 1.3E 5.C A. % = B./ C. = D. < = 6. : int m = 7, n = 12;, 3 A. n% = ( m% = 5) B. n% = ( m - m%5 ) C. n% = m - m%5 D. ( n% = m) - ( m% = 5 ) 7. A. 0 < = x < 90 B. i = j = = 0 C. ( char) (42 + 3 ) D. x + 1 = x + 1 8. int m = 2, n = 1, q;, q = n/ m + 2.5 ;, q A. 2.5 B. 3 C. 3.0 D. 2 9., A. x1 = 26.8% 3; B. x2 = j > 0; C. x3 = 01A ; D. x4 = 1 + 2 = 3; 10., A. a = 1/ b = 2 B. + + (a + b) C. a = a/ ( b = 5) D. y = int( a) + b 1. : float t = 2, x = 3.5;, : ( (int) x + 0.5 )/ t 2. : char x = A ;, x + = x% = x - 5 3. x, y, z, k int, x = ( y = 4, z = 16, k = 32 ), x 4. int m = 3, n = 4, x;, x = - m + + ; x = x + 8/ + + n;, x 5. # include < stdio.h > { int y = 3, x = 3, z = 1;

printf( %d, % d\ n, ( + + x, + + y ), z + 2) ; 6. # include < stdio.h > { int a, b; float c, d; a = - 23; b = 4; printf( a/ b = % d\ n, a/ b) ; printf( a% b = % d\ n, a % b) ; c = d = 5; c = c + (c = 1 ) ; d + = 10; printf( d/ = c: % f\ n, d/ = c) ; printf( a = % d, b = %d, c = % f, d = % f\ n, a, b, c, d ) ; 7. # include < stdio.h > { int x = 3, y = 5, z = 8; y = x + 3 x + y; z % = x + y + 3; x = y > z; printf( %d, % d, % d\ n, x, y, z) ; z = ( x + = x = + + y - z - - ) ; printf( %d, % d, % d\ n, x, y, z) ; 8. # include < stdio.h > { int x, y, z; x = y = z = 1; y + + ; + + z; printf( y = % d, z = %d \ n, y, z) ; x = ( - y + + ) + ( + + z) ; printf( x = %d, y = % d, z = % d\ n, x, y, z) ; x = y = 1 ; z = + + x y + + ; printf( x = %d, y = % d, z = % d\ n, x, y, z) ;

1., a b c d 2. a, b, c, : area = s ( s - a) ( s - b ) ( s - c), s = ( a + b + c)/ 2, a, b, c, area : sqrt( x ), math.h

4 C / : : scanf printf 4.1 4.1.1 C 1, 3,,, C C C, C, C 5 : 1 ;, : ; : x = y + z ; / /, y z, x y + z; / /,, i + + ; / / i 1

2 ;, : ( ) ;,, ( 7 ) : printf ( C P rogram ) ;, C Program 3, C 9, : : if switch ; : do while while for ; : break goto continue return 4 {,, : { x = y + z ; a = b + c; printf( % d% d, x, a) ; : { ;, 5 ;, : while( getchar ( )! = \ n ) ;,,, :,,, / 4.1.2 C C, / C C / / /, / : scanf/ printf getchar/ putchar gets/ puts, C, # include < > VC + + 6.0, stdio.h, : # include < stdio.h > # include stdio.h,,, ( Warning)

4.2 C,,,,, 4.2.1 printf,,, ( ) 1 printf printf : printf(, ) ;,,,, (, ),,,,, : printf( % d % d, a, b) ;, % d % d, a b, : 2 : % [ ],,,,, (1 ),, 4.1 : %, 4 1 % : int d = 15; printf( d = % d, d ) ;, 1 d, ; 3 d, ; % 2 d, d : d = 15

4.1 % d, % u % x, % X % u % o % f ( ), 6 %e, % E % g, % G % f % e %c % s, \ 0 4.1 # include < stdio.h > { int a = 15; float b = 123.1234567; char d = p ; printf( a = % d, %o, % x\ n, a, a, a) ; printf( b = % f, % e \ n, b, b ) ; printf( d = % c \ n, d) ; printf( % s\ n, programming ) ; : a = 15,17, f b = 123.123459, 1.231235e + 002 d = p progra mmi ng, a 15, b, 6 ;, (2 ),,, :

int a = 123, b = 12345 ; printf( a = %d,, a) ; printf( b = % d\ n, b) ; printf( H appy birthday! \ n ) ; : a = 123, b = 12345 H appy birthday! 1 printf, a =,, 2 printf b =, \ n ( 3 ),, printf,, (3 ) : l, h, d f u 4.2 4.2 # include < stdio.h > { long int a = 1234567; int b = 12345, c = 45678; double d = 1234567.123456789; printf( a = % ld, b = % hd \ n, a, b ) ; printf( c1 = % d, c2 = % hd \ n, c, c) ; printf( c3 = % ld, d = % lf \ n, c, d) ; : a = 1234567, b = 12345 c1 = 45678, c2 = - 19858 c3 = 45678, d = 1234567.123457 4.2 % ld % hd %lf, b c ( VC + + 6.0, 4, + 2147483647 2147483648, 2, + 32767 32768 ),, b, ; c,,,,,, l L (4 ),, %,,,, %,, : %d, ; % f % e % E,

; % s,, :. 4.3 4.3 % md m, m % m.nf m, n % ms m, m % m.ns m n, m 4.3 # include < stdio.h > { int a = 1, b = 100, c = 1000; float d = 123.4567 ; char ch [ ] = Cprogram ; printf( %3d\ n% 3d\ n%3d \ n, a, b, c) ; printf( %0.3d\ n% 0.3d\ n%0.3d \ n, a, b, c) ; printf( %7.2f\ n%5.2f\ n%2.7f\ n, d, d, d) ; printf( %5s \ n%7.3 s\ n% 2.6s \ n, ch, ch, ch) ; : 1 100 1000 001 100 1000 123.46 123.46 123.4567032 Cprogr am Cpr Cprogr,,, ( m > 0) 0( m = 0 m ), ( ) ;, ;,,, ;,

:,, (5 ) printf, 4.4 - :,, +, +,, - # 0, 0x ( ), ( - ) 4.4 # include < stdio.h > { int a = 64, b = 12345; float c = 123.45678 ; printf( %3d\ n, a) ; printf( % - 3d\ n, a) ; printf( %7.2f\ n, c) ; printf( % - 7.2f\ n, c) ; printf( %10 s\ n, Cprogram ) ; printf( % - 10 s\ n, Cprogram ) ; printf( % + 5d\ n, b) ; printf( % 5d\ n, b) ; printf( % # o\ n, a) ; printf( %o\ n, a) ; : 64 64 123.45 123.46 Cprogr am Cprogr am + 12345 0100 100 12345

4.2.2 scanf, stdio.h, 1 scanf scanf : scanf(, ) ;,, printf,,, &,,, scanf( % d% d, & a, & b), ( ) C, ( ) :, 4.5 # include < stdio.h > { int a ; float b, c ; printf( input a, b, c\ n ) ; scanf( % d% f % f, & a, & b, &c) ; printf( a = % d, b = % f, c = % f\ n, a, b, c) ;, scanf %d% f % f,, scanf ( % d% f % f, & a, & b, & c) ;,,,, < Tab >, : 7 4.6 7.9 7 4.6 7.9 Tab 7 4.6 7.9 : a = 7, b = 4.6, c = 7.9 : scanf % d, % f, % f,,,,,,,, : 7, 4.6, 7.9, scanf, int

a ;, scanf( % d, a) ;, scanf( % d, & a) ; 2 scanf, : % [ ],, (1 ), scanf 4.5 4.5 scanf d o x u f e c s ( ), a, b c, scanf % d f,, scanf, scanf( % d% f % f, &a, & b, &c) ; scanf( % f % f% f, &a, & b, & c) ; (2 ) scanf : ( ) l h, 4.6 4.6 scanf l h :, : int a, b, c; scanf( %2d% 3d%4d, & a, & b, &c) ; : 123456789, a b c 12 345 6789, :, 4.6 # include < stdio.h >

{ int a, b, c; scanf( % d% d% d, &a, & b, &c) ; printf( a = % d, b = %d, c = % d\ n, a, b, c) ;, : 1 2 3, : a = 1, b = 3, c = - 858993460 ( ),1 a, 2, 3 b c, l h : ( l) ( h ) l h d o x, % ld % lo % lx % hd % ho % hx, l f e ( % lf % le), double : long a; short b; scanf( %10ld% hd, &a, & b) ; a 10, b :123456789011, a 1234567890, b 11 (3 ), scanf,,, int a, b; scanf( % d, % d, &a, & b) ;,, : 1 < > 2, a 1, b 2,,,, : 1, 2 : scanf( a = %d, b = % f, c = % c, &a, & b, &c) ;, : 1, 2.1, a,,, ( a =, b =, c = ) scanf,, : a = 1, b = 2.1, c = a,,,,,,,, : int a ; char ch ; scanf( % d% c, &a, & ch) ; :23 < > a, a 23, ch a, 3 ch, : scanf ( % d% c, &a, & ch ) ; scanf ( % d % c, &a, &ch ) ; % d, a,

4.7 # include < stdio.h > { char a, b; printf( input character a, b\ n ) ; scanf( % c% c, & a, & b) ; printf( % c% c \ n, a, b) ; :, M N, : M, scanf % c% c, : M N, M, : MN, MN,,, 4.8 # include < stdio.h > { float a, b, c; scanf( % f, % f, % f\ n, & a, & b, &c) ; printf( a = % f, b = % f, c = % f\ n, a, b, c) ;, 3.5,4.6,7.9,,,, \ n, (, : 3.5, 4.6, 7.9 \ n, ), \ n,,,,, 4.3 C : getchar putchar, 4.3.1 getchar getchar : getchar ( ) : ( ), getchar,, char c; c = getchar( ) ; 4.9 # include < stdio.h >

{ char c; printf( input a character \ n ) ; c = getchar( ) ; putchar( c) ; getchar : getchar, getchar ( ),,,, getchar, ; : abcde, getchar a, 96, c 9, getchar 9, 9 : putchar ( getchar( ) ) ; printf( % c, getchar( ) ) ; 4.3.2 putchar putchar : putchar(ch), ch ( ) : ( ), : putchar ( A ) ; ( : A) putchar ( x) ; ( : x, : x ) putchar ( \ 101 ) ; ( : A, \101 A ) putchar, :, : p utchar ( abc ) p utchar ( abc ),, putchar ( A ) ; 4.10 # include stdio.h { char o = M, k = Y ; putchar( o) ; putchar( k) ; putchar( \ n ) ;

putchar( ) ; : MY,, getchar putchar( ch ),, scanf printf, % s,, gets puts,, C,, \ 0, \ 0, C,, : char ch [100 ] = H ello World ; ( 6 ) 4.3.3 gets gets : gets ( ) : ( ) gets,, scanf 4.3.4 puts puts : puts( ) : 4.11 # include stdio.h { char c[ ] = Hello - World! \ n, st[ 15 ] ; printf( input string: ) ; gets ( st) ; printf( result is: % s \ n, st) ; puts (c) ; (, H ello World ) : input string: H ello World res ult is: H ello World H ello - World!

, puts printf, printf : / scanf/ printf, / getchar/ putchar, / gets/ puts /, C,, scanf printf 1. int n1 = 10, n2 = 20; printf(, n1, n2 ) ; : n1 n2,, n1 = 10 n2 = 20 2. : { int i, j; scanf( i = % d, j = % d, &i, & j) ; printf( i = %d, j = % d\ n, i, j) ; : i 10, j 20, 1. 3 ( 10.0, 20.0, 5.0 ), 3 sum product average 2. : sizeof ( ), 3. ( 20, 10 ), a b, : int 4, long int, float

5 if switch, while do - while for, :,, :,,, 5.1 C 3 1.1.3, ( ), : (1 ),, (2 ),,, (3 ),,,,,, ;

,,, ( ) ;,,,, 3,, 4.1.1 C,,,,, C, C, ( if switch ) ( while do - while for ) 5.2,,, 5.1 3, 1 2 3 C,,, {,,, x y, : 5.1 { temp = x; / / x temp x = y; / / y x y = temp; / / temp y temp temp, : { int temp; temp = x; x = y; y = temp;,,,, ( ),,,,,,,, ( ),,

, 5.1, C F : F = 1.8 C + 32 : # include < stdio.h > { float C, F; printf( : ) ; scanf( % f, & C ) ; F = 1.8 C + 32; printf( : %6.2f\ n, F ) ;, 37, : : 37 :98.60 / / 5.2 r = 1.5, h = 3,,,,, : : L = 2 r, S = r 2, V = r 2 h 3, # define, PI, PI 3.1415926 :, C,,, C, : # include < stdio.h > # define PI 3.1415926 / / PI { double r, h, l, s, v; printf( r = ) ; scanf( % f, & r ) ; / / printf( h = ) ; scanf( % f, & h ) ; / / l = 2 PI r ; s = PI r r ; v = PI r r h ; printf( l = %6.2f\ n, l ) ;

printf( s = %6.2f\ n, s ) ; printf( v = % 6.2f\ n, v ) ; : r = 1.5 h = 3 l = 9.42 s = 7.07 v = 21.21 5.3 2x 2 + x - 3 = 0 : ax 2 + bx + c = 0, b 2-4ac 0, : x1 = - b + b2-4ac 2a a = 2, b = 1, c = - 3, b 2 x2 = - b - b2-4ac 2a - 4ac = 25 > 0, : a b c, b 2-4ac p, sqrt,, math.h, math.h : # include < stdio.h > # include < math.h > { float a, b, c, x1, x2, m; printf( a, b, c : ) ; scanf( % f, % f, % f, &a, & b, & c) ; m = sqrt( b b - 4 a c) ; x1 = ( - b + m ) / ( 2 a ) ; x2 = ( - b - m) / ( 2 a ) ; printf( x1 = % f\ n, x1 ) ; printf( x2 = % f\ n, x2 ) ; : a, b, c : 2,1, - 3 x1 = 1.000000 x2 = - 1.500000

5.3,,,, 5 2 5.3 ax 2 + bx + c = 0, b 2-4ac 0, b 2-4ac < 0 b 2-4ac 0,,, ( ) C, if switch,, 5.3.1 if 1 if C if : if if - else (1 ) if : if ( ) 1; :, ( 0), 1 ; (, 0 ),, (if ) : if, 5.2 1,,,,,, 5.2 if 5.4, : x, x, x < 0, - x x ;, x if : # include < stdio.h > { int x; printf( x : ) ; scanf( % d, & x) ; if ( x < 0) x = - x; printf( x = % d\ n, x) ;

: x : x = 416-416 5.5 3, x y z, 3, :, x y, x ;, x z, x,,3 x ;, y z, y,, t : # include < stdio.h > { int x, y, z, t ; printf( 3 : ) ; scanf( % d% d%d, & x, & y, &z) ; if ( x < y) {t = x; x = y; y = t; / x, y / if( x < z) {t = z; z = x; x = t; / x, z / if( y < z) {t = y; y = z ; z = t ; / z, y / printf( : % d % d % d\ n, x, y, z) ; : 3 : 45 78 23 :78 45 23 (2 )if - else : if ( ) else 1; 2; :, ( 0), 1 ; (, 0 ), 2 : if - else,, 5.3, 1 2 5.6, :, 5.3 if - else

: # include < stdio.h > { char ch ; printf( Input a character: ) ; ch = getchar ( ) ; if( ch > = a & & ch < = z ch > = A & & ch < = Z ) printf( It is a lett er.\ n ) ; else printf( No, it is not a let ter.\ n ) ; : Input a character: A It is a let ter. Input a character: 8 No, it is not a letter. 2 if if, 1 2, C, if if, if (1 ) else - if else - if if, if - else 2 if, if else - if : if ( 1 ) 1; else if ( 2) 2 ; else else if ( n - 1) n - 1 ; else n; : 1, 1 ( 0 ), 1, if ;, 2, 2 ( 0), 2, if ;, ;,, n : else - if, 5.4, else - if if,,, else n,,

5 4 else - if 5.7,, 85, 60, : score, :, 85 score 100;,85 > score 60;, 0 score < 60, else - if : # include < stdio.h > { float scor e; printf( Input score : ) ; scanf( % f, & score) ; if ( score > = 85 & & score < = 100 ) printf( Excellent.\ n ) ; else if( score > = 60 & & score < 85) printf( Pass.\ n ) ; else if( score > = 0 & & score < 60 ) printf( No pass.\ n ) ; else printf( Error score.\ n ) ; : Input score : 90 Excellent. Input score : 75 Pass.?, score > = 60 score > = 0, (2 ) if if, if,, if : 1: if ( 1 )

if ( 2) 1; else 2 ; else 3; 2: if ( 1 ) { if ( 2 ) 1; else 2; 3: if ( 1 ) 1 ; else if ( 2 ) 2; else 3; 4: if ( 1 ) if ( 2 ) 1; else 2; else if ( 3 ) 3; else 4;,, if, if if - else, : if ( x > 0) if ( x > 100 ) y = 1; else y = 0; else if, : if if - else, else if if ( x > 0) if ( x > 100 ) y = 1; else y = 0; if - else 1 if, else if if ( x > 0) if ( x > 100 ) y = 1; else y = 0;, C : else if,, if,, : if ( x > 0) { if ( x > 100 ) y = 1 else y = 0;,,, else, if if 2,,,,, 5.8 ax 2 + bx + c = 0 : 5.3, ax 2 + bx + c = 0, b 2-4ac 0,, : a = 0 b 0,, x = - c/ b ; b 2-4ac = 0, : x = - b/ 2a ;

b 2-4ac 0, : x1 - b + b 2-4ac 2a, x2 - b - b 2-4ac ; 2a b 2-4ac < 0, : x1 = p + qi, x2 = p - qi, p = - b 2a q = - ( b 2-4ac) 2a, if, a b c, : if ( a = = 0 & & b = = 0 & & c = = 0 ) ; else if ( a = = 0 & & b!= 0 ) ; else { b 2 if ( m > = 0) else - 4ac m; ; { p ; : # include < stdio.h > # include < math.h > q; ; { float a, b, c, x1, x2, p, q, m; printf( Enter 3 coefficients a, b, c: ) ; scanf( % f, % f, % f, &a, & b, & c) ; if( a = = 0 & & b = = 0 & & c = = 0 ) printf( any value \ n ) ; else if ( a = = 0 & & b!= 0 ) else printf( x = % f\ n, - c/ b) ; { m = b b - 4.0 a c; if( m > = 0 ) { x1 = ( - b + sqrt( m) ) / ( 2.0 a ) ; else x2 = ( - b - sqrt( m) ) / ( 2.0 a ) ; printf( x1 = % f\ n, x1 ) ; printf( x2 = % f\ n, x2 ) ; / /

{ p = - b / ( 2.0 a ) ; q = sqrt( - m) / ( 2.0 a ) ; printf( x1 = % f + % fi \ n, p, q) ; printf( x2 = % f - : % fi \ n, p, q) ; Enter 3 coefficients a, b, c: 2, 1, - 1 x1 = 0.500000 x2 = - 1.000000 Enter 3 coefficients a, b, c: 2, 1, 1 x1 = - 0.250000 + 0.661438i x2 = - 0.250000-0.661438i 5.3.2 switch else - if if,,, if, C switch switch : switch ( ) { case 1 : 1; break ; case 2 : 2; break ; case n: n ; break; default : n + 1; :,,, ;, default, break, switch - case, ( ) : switch,,,, 5.5

5 5 break switch switch, : switch case, case,, { default case, case case default, default, case, switch, C, switch : switch ( x) { case 1: switch (y ) { case 0: a + + ; break ; case 1: b + + ; break; break; case 2: a + + ; break ; case : switch ( x) { case 1: case 2: case 3: a + + ; b + + ; break; case 4: c + + ; break;, switch break,, break break,,, break break switch ( 5 6) : switch ( )

{ case 1 : 1; case 2 : 2; case n: n ; default : n + 1; 5 6 break switch 5.6, 2, 2 n n + 1 switch : i = 1, switch (i) { case 0: printf( %d, i) ; break ; case 1: printf( %d, i) ; break ; case 2: printf( %d, i) ; break ; default : printf( % d, i) ; :1 switch (i) { case 0: printf( % d, i) ; case 1: printf( % d, i) ; case 2: printf( % d, i) ; default: printf( % d, i) ; :111, case 1 switch( y) break, case 0 a + + ; break;, switch ( y), case 2 a + + ; break;, switch( x), printf, : a = 2, b = 0 # include < stdio.h > { int x = 1, y = 0, a = 0, b = 0; switch ( x) { case 1: switch ( y) { case 0: a + + ; break; case 1: b + + ; break; case 2: a + + ; break; case 3: b + + ; break;

printf( a = %d, b = % d\ n, a, b) ; 5.9,, A B C D E 90 A, 80 89 B, 70 79 C, 60 69 D, 60 E, :, 6, score, else - if, 5.7 : if ( score > = 90 & & score < = 100 ) printf( A \ n ) ; else if( score > = 80 & & score < 90 ) printf( B\ n ) ; else if( score > = 70 & & score < 80) printf( C \ n ) ; else if( score > = 60 & & score < 70) printf( D\ n ) ; else if( score > = 0 & & score < 60 ) printf( B\ n ) ; else printf( error! \ n ) ; switch switch case score 0 100 101, 101 case ( 101 case, ), (case ), caes, 100, 10, 90 80 70 ;,,, 90, 9, 80, 8, score/ 10 switch, case 0 9, 100 10 : # include < stdio.h > { int score; printf( Please enter score : ) ; scanf( % d, & score) ; switch ( score/ 10 ) { case 10: case 9: printf( % d A \ n, score) ; break; case 8: printf( % d B\ n, score) ; break; case 7: printf( % d C\ n, score) ; break; case 6: printf( % d D\ n, score) ; break; case 5: case 4: case 3: case 2: case 1: case 0: printf( % d E \ n, score) ; break;

default : printf( Input error! \ n ) ; : Please enter score : 85 85 B Please enter score : 101 101 A Please enter score : 110 Input error!,,, 101, A,, 101 109, score/ 10 10, case 10:, A if, 100, if - else switch : # include < stdio.h > { int score; printf( Please enter score : ) ; scanf( % d, & score) ; if( score < 0 score > 100) else printf( Input error! \ n ) ; { switch ( score/ 10) { case 10: case 9: printf( %d A \ n, score) ; break; case 8: printf( %d B\ n, score) ; break; case 7: printf( %d C\ n, score) ; break ; case 6: printf( %d D \ n, score) ; break; case 5: case 4: case 3: case 2: case 1: case 0: printf( %d E \ n, score) ; break;

5.4,,,,, C while do - while for,, break continue 5.4.1 while while, :, while : : while ( ) ;, ( 0), ;,,,, ( 0), while, while, 5.7 : while :,, : (1 ), (2 ),, {,, 5 7 while (3 ), ;, ( ) 5.10 n, s = 1 + 2 + 3 + + n, while :, : s, 0,, s, n, n : # include < stdio.h > { int i, n, s ; printf( Please enter n: ) ; scanf( % d, & n) ; / / n,n s = 0 ; i = 1 ; / /

while (i < = n) / /, { s = s + i ; / / i i + + ; / / printf( 1 + 2 + 3 + + % d = % d\ n, n, s) ; : Please enter n:50 1 + 2 + 3 + + 50 = 1275 5.11,, : # include < stdio.h > { char c; int num = 0; printf( : ) ; / / num 0 while( (c = getchar( ) )! = \ n ) / /,, num + + ; printf( = % d\ n, num) ; : : hi, ABC = 6 5.4.2 do - while / / 1, do - while :, do - while : do{ ; while ( ) ; :,, ( 0 ),, 5.8 : do - while :, while,, do - while :,,,, 5 8 do - while

;,,, { 5.12 n, s = 1 + 2 + 3 + + n, do - while : # include < stdio.h > { int i, n, s ; printf( Please enter n: ) ; scanf( % d, & n) ; s = 0 ; i = 1 ; do / / { s = s + i ; / / i i + + ; / / while (i < = n ) ; / /, printf( 1 + 2 + 3 + + % d = % d\ n, n, s) ; : Please enter n:50 1 + 2 + 3 + + 50 = 1275,, while do - while,,,,,, : (1 ) while int i, s; s = 0 ; i = 5 ; while (i < 5 ) { s = s + i; i + + ; printf( s = % d, s) ; : s = 0 ( 2) do - while int i, s; s = 0; i = 5; do { s = s + i; i + + ; while ( i < 5) ; printf( s = % d, s) ; : s = 5 : while, i < 5, ; do - while,, i < 5, 5.4.3 for for C, for while, while for : for ( 1; 2; 3 ) ;

: 1, 2, ( 0),, 3, 2,, 5.9 : for, 1,, ; 2,, ; 3, : for,, for ( ; i < 10 ; i + + ) sum + = i; for ( ; ; ) sum + = i ; ; / / i for 1 3, for (i = 0, j = 0 ; i < 100 ; i + +, j + + ) b[i] = a[j] ; / /, 5 9 for,, { ;, 5.13 n, s = 1 + 2 + 3 + + n, for : # include < stdio.h > { int i, n, s ; printf( Please enter n: ) ; scanf( % d, & n) ; for (i = 1, s = 0; i < = n; i + + ) s = s + i ; printf( 1 + 2 + 3 + + % d = % d\ n, n, s) ; : Please enter n:50 1 + 2 + 3 + + 50 = 1275 5.14 n, n! :,, : s,, s 1,, s = s i(i = 1, 2, n ), n, n! : # include < stdio.h >

{ int i, n, s ; printf( Please enter n: ) ; scanf( % d, & n) ; for (i = 1, s = 1; i < = n; i + + ) s = s i ; printf( % d! = 1 2 %d = % d\ n, n, n, s ) ; : Please enter n:5 5! = 1 2 5 = 120,, 5.4.4 C while do - while for,,,, : (1 ),, ( 2 ) for while, ; do - while for while, do - while (3 ) while do - while,, for (4 ) do - while (5 ) for,, 5.4.5 C,,,, C,,,,,, 5.15 1! + 2! + 3! +...+ n!, n :,, i i, i n, j i,

i, i : # include stdio.h { int i, j, n, t, sum = 0; printf( please Input n : ) ; scanf( % d, & n) ; for (i = 1; i < = n; i + + ) { t = 1 ; for (j = 1 ; j < = i; j + + ) t = t j; sum + = t ; / / n, / / i, / / i printf( sum = % d, sum) ; / / : please Input n : 8 sum = 46233, i i - 1 i, : # include stdio.h { int i, n, t, s um = 0; printf( please Input n : ) ; scanf( % d, & n) ; t = 1 ; for (i = 1; i < = n; i + + ) { t = t i ; sum + = t ; printf( sum = % d\ n, sum ) ; 5.16, 1 1 = 1 1 2 = 2 1 3 = 3 1 8 = 8 1 9 = 9 2 2 = 4 2 3 = 6 2 4 = 8 2 9 = 18 9 9 = 81 :, 9 1,, i, 1 9, j i 9,

: # include < stdio.h > { int i, j, k ; for ( i = 1; i < = 9; i + + ) / /, 9 { for ( j = i; j < = 9; j + + ) / /, 9 - i + 1 { k = i j; printf( % d %d = % 2d, i, j, k ) ; printf( \ n ) ;, j = i; j < = 9; j = 1; j < = 9; j = 1; j < = i;,, 5.5,,, C break continue, C goto goto, goto, 5.5.1 break break : break; break switch, switch, switch, break switch, switch, switch 5.17 10,, : for,,, 10, i > 10 ;, break, : # include < stdio.h > { int s um = 0, x, i; printf( 10 : \ n ) ; for (i = 1; i < = 10; i + + ) / / i > 10, { scanf( % d, & x) ; / / x

if ( x < 0) break; / / x < 0, sum = sum + x ; printf( \ ns um = % d\ n, sum) ; : 10 : 5 4 3 8 12 61 0-1 sum = 93 5.5.2 continue continue : continue ; / / continue,, while do - while, ( ) ; for, 3 continue break : continue, ; break 5.18,, : while,, continue ( ),, : # include < stdio.h > { char c; printf( : ) ; while( (c = getchar( ) )! = \ n ) { if( c > = A & & c < = Z ) continue ; putchar (c) ; printf( \ n ) ; : : ABheKllow12 hellow12

5.6 5.19, : 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1 1 2 3 4 5 4 3 2 1 1 2 3 4 5 6 5 4 3 2 1 1 2 3 4 5 6 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 :, 1 9, 9, i ( 1 i 9 ), 1 i, i 1,, i, ( for ) : # include < stdio.h > { int i, j; for (i = 1; i < = 9; i + + ) { for ( j = 1 ; j < i; j + + ) printf( % 3d, j) ; for ( j = i; j > 0; j - - ) printf( % 3d, j) ; printf( \ n ) ; : 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1 1 2 3 4 5 4 3 2 1 1 2 3 4 5 6 5 4 3 2 1 1 2 3 4 5 6 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1,,,,, blank

# include < stdio.h > { int i, j, b lank = 30; for (i = 1; i < = 9; i + +, blank - = 3 ) { for ( j = 1 ; j < blank ; j + + ) printf( ) ; for ( j = 1 ; j < i; j + + ) printf( % 3d, j) ; for ( j = i; j > 0; j - - ) printf( % 3d, j) ; printf( \ n ) ; : 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1 1 2 3 4 5 4 3 2 1 1 2 3 4 5 6 5 4 3 2 1 1 2 3 4 5 6 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 5.20 2008 8 8 ( ) : 2008 8 8, 2008, 2008, 7 ( ),, : # include < stdio.h > { int year = 2008, month = 8, day = 8 ; int weekday = 2 ; int i, num, yeardays = 0 ; / / 2008-8 - 8 2008 for (i = 1; i < month; i + + ) { / / switch (i) { case 1: case 3: case 5: case 7: case 8: case 10: / / 2008-1 - 1

case 12: num = 31 ; break ; / / 31 case 4: case 6: case 9: case 11: num = 30 ; break ; case 2: if ( ( year %4 = = 0 & & year %100! = 0) / / 30 year %400 = = 0) num = 29; / / 29 else num = 28; break ; default : n um = 0; yeardays + = num; yea rdays = yeardays + day; / / 2008-8 - 8 weekday = ( yeardays - 1 + weekday ) %7; / / 28 printf( % d % d % d % d\ n, year, month, day, weekday) ; : 2008 8 8,, : # include < stdio.h > { int year, month, day, weekday; int i, num, yeardays = 0 ; / /, : 2008-8 - 8 printf( : ) ; scanf( % d - % d - %d, & year, & month, & day) ; / / 1 1 printf( % d 1 1 :, year ) ; scanf( % d, & weekday) ; / / for (i = 1; i < month; i + + ) { / / switch (i) { case 1: case 3: case 5:

case 7: case 8: case 10: case 12: num = 31 ; break ; case 4: case 6: case 9: case 11: num = 30 ; break ; case 2: if ( ( year %4 = = 0 & & year %100! = 0 ) year % 400 = = 0 ) num = 29; else num = 28; break; default : n um = 0; yeardays + = num; yea rdays = yeardays + day; / / 1 yeardays = ( yeardays - 1) ; / / weekday = ( yeardays + week day) % 7; printf( % d % d % d % d\ n, year, month, day, weekday) ; : : 2008-5 - 1 2008 1 1 : 2 2008 5 1 5.21 100, 10 : 1, 1 k : k 2, 3, 4,, k - 1,, k,, k, 2, 3,, k for flag, 1, j 2 k,, k j, flag 0, for,, flag 1, k : flag = 1; for ( i = 2; i < = sqrt( k) ; i + + )

if ( k % i = = 0) { flag = 0; break; if ( flag = = 1) printf( %d, k) ;, 100, 100,, k 2 100, for for ( k = 2 ; k < = 100 ; k + + ) { k ;, k;, 10, num,, 1, 10,, : # include < stdio.h > # include < math.h > { int k, j, num = 0, flag; for ( k = 2 ; k < = 100 ; k + + ) { flag = 1; for ( j = 2 ; j < = sqrt( k) ; j + + ) if ( k % j = = 0 ) { flag = 0; break ; if ( flag = = 1) { printf( %3d, k ) ; num + + ; if ( num% 10 = = 0) printf( \ n ) ; printf( \ n 100 %d.\ n, num) ; : 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 100 25 5.22 e, e = 1 + 1 1! + 1 2! + 1 3! + + 1, n! 10-5, : : e = e + term, term,, 1 2! = 1 1! 2, 1 3! = 1 3,,, : term 2! n = t ermn - 1 n, C : term = t erm/ n;, term 1.0, n 1, n n = n + 1, while do - while, term <

10-5, count, 0, 1, count, n : 1 : (1 ) while # include < stdio.h > void { int n, count = 0 ; double term, e; e = 1; term = 1.0; n = 1; while (term > = 1e - 5 ) / / 1 e / / / / { term = term/ n; / / n + + ; e = e + term; count + + ; / / / / e / /, 1 printf( e = % lf, = %d \ n, e, count) ; (2 ) do - while # include < stdio.h > { int n = 1, count = 0; double term = 1, e = 0; do { e = e + term; / / e term = term/ n; n + + ; count + + ; while ( term > = 1e - 5) ; e = e + term; / / / / 1 / / printf( e = % lf, = %d \ n, e, count) ; : e = 2.718282, = 9,, 5.23 ( Fibonacci) 12 : 1,,

:, 3, 3, :, : f1 = 1, f2 = 1, fi = fi - 1 + fi - 2 (i 3 ), 1 + 1 = 2, 1 + 2 = 3, 2 + 3 = 5,, 12 144, 12, for : # include < stdio.h > { int f1, f2, f, i; f1 = 1; / / f2 = 1; / / printf( %10d%10d, f1, f2 ) ; for ( i = 3; i < = 12; i + + ) { f = f1 + f2; / / printf( %10d, f) ; if( i % 4 = = 0 ) printf( \ n ) ; / / 4 f1 = f2; / / f2 = f; printf( \ n ) ; : 1 1 2 3 5 8 13 21 34 55 89 144, f = f1 + f2,, f1,, f f2 + f1, f1, f2, f2 : f1 = f1 + f2 ; f2 = f2 + f1 ;,, : # include < stdio.h >

int main( ) { int f1, f2, i ; f1 = f2 = 1 ; / / 1 2 printf( %10d%10d, f1, f2 ) ; for ( i = 2; i < = 6; i + + ) { f1 = f1 + f2 ; / / f2 = f2 + f1 ; / / printf( %10d%10d, f1, f2 ) ; if( i % 2 = = 0 ) printf( \ n ) ; / / 4 printf( \ n ) ; 5.24, 100 100, 5, 3, 1 3,, :, ;, ;,,? :,,,,,,,, x y z, : (1 ) : x + y + z = 100( ) (2 ) : 5x + 3y + (1/ 3 )z = 100 ( ), 15x + 9y + z = 300, x y z, 100 20, 33,, 100, 0 x 20, 0 y 33, 0 z 100, x y z, x y z,, : # include < stdio.h > int main( ) { int x, y, z; for ( x = 0; x < = 20; x + + ) for ( y = 0; y < = 33; y + + ) for (z = 0; z < = 100 ; z + + ) : if( x + y + z = = 100 & & 15 x + 9 y + z = = 300 ) printf( x = % d, y = % d, z = % d\ n, x, y, z) ; x = 0, y = 25, z = 75

x = 4, y = 18, z = 78 x = 8, y = 11, z = 81 x = 12, y = 4, z = 84 4, 21 34 101 = 72114, x y, z 100 - x - y,, x y, 714, : # include < stdio.h > { int x, y, z; for ( x = 0; x < = 20; x + + ) for ( y = 0; y < = 33; y + + ) { z = 100 - x - y; if( 15 x + 9 y + z = = 300 ) printf( x = % d, y = % d, z = % d\ n, x, y, z) ;, C, C ( ) {,,, C if switch, if, C if else switch break, while for do - while, while for,, ; do - while,,, for, while do - while break continue, : continue, break

1. ( s1 s2 C ), : A. if ( a) s1 ; else s2; B. if (! a) s2; else s1; C. if ( a! = 0) s1; else s2; D. if ( a = = 0 ) s1; else s2 ; 2. { int a = 3, b = 4, c = 5, d = 2; if( a > b ) if( b > c) else printf( % d, d + + ) ; printf( % d, + + d) ; printf( % d\ n, d ) ; A. 2 B. 3 C. 33 D. 34 3. while( x) x : A. x = = 0 B. x = = 1 C. x! = 1 D. x! = 0 4., 5!, A. for (i = 1, p = 1; i < = 5; i + + ) p = i; B. for( i = 1; i < = 5; i + + ){ p = 1 ; p = i; C. i = 1; p = 1; while(i < = 5 ){p = i; i + + ; D. i = 1; p = 1; do{p = i; i + + ; while(i < = 5 ) ; 5. { int i = 0, a = 0 ; while(i < 20) { for ( ; ; ) { if( (i%10) = = 0) break; else i - - ; i + = 11; a + = i; printf( % d\ n, a) ; A. 21 B. 32 C. 33 D. 11 5

1. 3, 2.C, if, else if 3. C, if - goto 4., break, continue 5. { int i; for (i = 0; i < 3; i + + ) switch(i) { case 0: printf( %d, i) ; case 2: printf( %d, i) ; default : printf( % d, i) ; 6. { int x = 1, y = 0, a = 0, b = 0; switch ( x) { case 1: switch ( y) { case 0: a + + ; break; case 1: b + + ; break; case 2: a + + ; b + + ; break ; printf( % d %d \ n, a, b) ; 7., while int i = 0; while (i < 10) { if (i < 1) continue ; if (i = = 5) break; i + + ; 8. 1234, { int n, sum = 0 ;

n = 1234; do { sum = sum + ( n%10) ( n%10) ; while( n ) ; printf( sum = % d, sum) ; 1. : y = e - x x > 0 ; 1 x = 0, x, y - e x x < 0 2. switch,, ( ) 3. 1 + 3 + 5 + 7 + + 99 4. 1-1/ 2 + 1/ 3-1/ 4 + + 1/ 99-1/ 100 +, 10-4 5. 20, : (1 ) ; (2 ) ; (3 ) 6. 1, 2, 3, 4 4, ( 4, : 1111,1122, 1212 ). 7., 3,., 153, 153 = 1 1 1 + 5 5 5 + 3 3 3 8.,, 9. 100m,, 10, ( m )? 10? 10.,

6, :, :, 6.1 6.1.1,,,,, 1 000, 1 000, 1 000,, C,,,,,,

6.1.2 1 (1 ),,, C : [ ] ;,,,,, : int n um[ 10] ;, num, 10, num [ 0 ] num [ 1 ] num [9 ], :,, int n; scanf( % d, & n) ; int a[ n ] ; 1 0, 1 (2 ), C ( static), C, : [ ] = { 1, 2,, n;, 0,,, 0,, int n um[ 5 ] = {10, 20,30, 40,50 ; num, num [ 0 ] num [ 1 ] n um [ 2 ] num [ 3 ] num[ 4] 10 20 30 40 50,, VC + + 6.0 0, int num[ 5] = {10, 20;, num num [ 0 ] = 10, num [ 1 ] = 20, num[ 2] num[ 3] num[ 4] 0, static int num[5 ] = {10,20 ;

VC + + 6.0,, int num [5 ] = {10,, 30, 40, 50; static int num[5 ] = {10,, 30,40, 50;, int num[ ] = {10, 20,30, 40,50 ; num num[ 0] num[ 1] num[ 2 ] num [3 ] num[ 4] 5, 10 20 30 40 50 : C,,, int num [5 ] ; num[ 5] = {10, 20, 30, 40, 50; 2 C : int num [10] ;, n um 10, num[ 0 ] num [ 9 ], 6.1 num num [0 ] num[1 ] num[2 ] num[ 3] num[4 ] num[ 5] num[ 6] num[ 7] num[ 8] num[ 9] 3 6.1 num,, : [ ], [ 0, - 1], int m = 3 ; int a[ 4], b[ 3] = {1,2,3; scanf( % d, a) ; / / a[0] a[1 ] = 10; a[2 ] = b[ m - 1] ; scanf( % d, & a[3 ] ) ; # define size 4 int a[ size], b[ size] ; scanf( % d, & a) ; / / printf( % d, a) ; / / printf( % d, a[ size] ) ; / / b = a ; / / C,

, ( ), b = a : a [ size] printf a [ size] size, size, printf a[ size], C 0 size - 1,,,,, 6.1 10, : 10, 10, ( ),, count1 count2, ;, 2, count2 1, count1 1; : # include < stdio.h > { int i, count1 = 0, count2 = 0; int data[ 10 ] ; for (i = 0; i < 10; i + + ) scanf( % d, & data[i] ) ; for (i = 0; i < 10; i + + ) { if( da ta[ i] %2 = = 0) count2 + + ; else count1 + + ; printf( : % d\ n, count2) ; printf( : % d\ n, count1) ; :,? 6.2 5.23, 6 : # include < stdio.h > { int i; int f[12] = {1, 1; / / for (i = 2; i < 12; i + + ) f[i] = f[i - 2] + f[i - 1 ] ; / /

for (i = 0; i < 12; i + + ) { printf( %10d, f[ i] ) ; if( (i + 1 ) %6 = = 0) printf( \ n ) ; / / 6.2 1 (1 ), : [ ] [ ] ;,,, 0, int xx [2 ] [ 2] ;, xx 2 2, 4, 1 xx [ 0] [ 0 ] xx [ 0] [ 1 ] 2, 2 xx [1 ] [ 0] xx[ 1] [1 ] 2, 4 (2 ) : [ ] [ ] = {{ 1,, { n, ;, int data[ 2] [3 ] = {{1, 2, 3, {4, 5, 6; data[0 ] [ 0] data[0 ] [ 1] data [0 ] [ 2] data[ 1] [0 ] data[1 ] [ 1] data[1 ] [ 2] 1 2 3 4 5 6 VC + + 6.0, (, ),, 0 ( ), int num [3 ] [ 3 ] = {{1, 2, {4, 5, 6;, num [0 ] [ 0] num[ 0] [1 ] num [0 ] [ 2] num [ 1 ] [ 0 ] num [ 1 ] [ 1] num [ 1] [2 ], num [2 ] [ 0] num[ 2] [1 ] num[2 ] [ 2] 1 2 0 4 5 6 0 0 0, int num [3 ] [ 3] = {{1, 2, 3, {, {4, 5, 6; int num [3 ] [ 3] = {{1, 2, 3,, {4, 5, 6; int num [3 ] [ 3] = {{1,, 3, {4, 5, 6; [ ] [ ] = { 1,, n, ;,,, int num[ 2] [2 ] = {1, 2, 3, 4; : num[ 0] [0 ] num [0 ] [ 1] num[ 1] [0 ] num[ 1] [1 ] 1 2 3 4,,, int num [3 ] [ 2] = {1, 2, 3, 6;,,, C

, int num[ ] [ 3 ] = {1, 2, 3, 4, 5, 6, 7, 8, 9 ;, int num [3 ] [ ] = {1, 2, 3, 4, 5, 6, 7, 8, 9; 2,,, 1,, int a[2 ] [ 5 ] ;, a 6.2 a[0 ] [ 0] a[0 ] [ 1] a[ 0] [2 ] a[ 0] [3 ] a[ 0] [4 ] a[ 1] [0 ] a[ 1] [1 ] a[ 1] [2 ] a[ 1] [3 ] a[ 1] [4 ] 6.2 a,, a a[0 ] a[ 1] 2, a[0 ] a[1 ] 5, : a[0 ] : a[ 0] [0 ], a[0 ] [ 1], a[0 ] [ 2], a[ 0] [3 ], a[0 ] [ 4] a[1 ] : a[ 1] [0 ], a[1 ] [ 1], a[1 ] [ 2], a[ 1] [3 ], a[1 ] [ 4], 6.3 : 4 4, :,,,,, : # include < stdio.h > { int i, j, k, a[ 4] [4 ] ; printf( 16! \ n ) ; for (i = 0; i < 4; i + + ) { for (j = 0 ; j < 4 ; j + + ) scanf( % d, & a[i] [j] ) ; printf( \ n : \ n ) ; for (i = 0; i < 4; i + + ) { for (j = 0 ; j < 4 ; j + + ) printf( %5d, a[i] [j] ) ; printf( \ n ) ; printf( : \ n ) ; for (i = 0; i < 4; i + + ) { for (j = 0 ; j < 4 ; j + + )

3 { printf( %5d, a[j] [i] ) ; printf( \ n ) ; 3 3, : [ 1 ] [ 2 ] [ 3] ;,, : int x[ 2] [ 2 ] [ 3 ] ;, x 12, : x[ 0] [0 ] [ 0], x[ 0] [0 ] [ 1], x[ 0] [0 ] [ 2], x[ 0] [1 ] [ 0], x[ 0] [1 ] [ 1], x[ 0] [1 ] [ 2] x[ 1] [0 ] [ 0], x[ 1] [0 ] [ 1], x[ 1] [0 ] [ 2], x[ 1] [1 ] [ 0], x[ 1] [1 ] [ 1], x[ 1] [1 ] [ 2], 6.3 1,, : char str [10] ; str, str [ 0 ] str [ 1 ]... str [ 9 ], 10, char str[ 8 ] = { w, e, l, c, o, m, e ;, char str1[ ] = { w, e, l, c, o, m, e ;,,, str [7 ] ;,, str1 7 2 C,,, \ 0, : welcome 7, 8, \0 \0,, welcome 7, char str2 [ 8 ] = { w, e, l, c, o, m, e, \0 ;, str2, str1,

, char str2 [ 8 ] = { welcome ;,, char str2 [8 ] = welcome ;, welcome, \ 0, \0, \ 0, 1, : char str3 [ 7] = welcome ;,, \ 0 str3,,,, char str3[ ] = welcome ;,,,, str3 8, \0 3,,, \ 0 : char s1[ 10 ] = { w, e, l, c, o, m, e ; char s2[ 10 ] = welcome ; s1 7,, s2, \0, \ 0 welcome,, \0, 6.3 6.4 s1 s2 w e l c o m e 6.3 s1 w e l c o m e 0 6.4 s2,,, ;, \ 0, \ 0, \0, 4,, (1 ) getchar scanf, char str[ 5] ;, for (i = 0; i < 5; i + + ) str[ i] = getchar( ) ;, for ( i = 0; i < 5; i + + ) scanf( % c, & str [i] ) ;, getchar scanf, \ 0,

,,, getchar scanf, (2 ) gets scanf, char xx[ 10] ; gets ( xx ) ; char xx[ 10 ] ; scanf( % s, x x) ; (3 ) putchar printf, for (i = 0; i < 10 ; i + + ) putchar ( xx [i] ) for(i = 0; i < 10; i + + ) printf( % c, xx [i] ) ; (4 ) puts printf, puts ( xx) ; printf( % s, xx) ; 5,, : char name[ 10 ] [ 80 ] ;, name 10, 80 ( 79, \ 0 ),, char str [ 3 ] [ 6 ] = { Tom, Jack, Mike ; char str[ ] [ 6] = { Tom, Jack, Mike ;, 6 5: str[ 0] T o m \ 0 str[ 1] J a c k \ 0 str[ 2] M i k e \ 0 6.5 str 6.4, :,, : # include < stdio.h > { char str1 [40], str2[ 20 ] ; int i, k; printf( \ n ) ; scanf( % s, str1) ; printf( \ n ) ; scanf( % s, str2) ; for (i = 0; str1[ i]! = \ 0 ; i + + ) ; for ( k = 0 ; str2 [ k]! = \0 ; k + + ) { str1[i] = str2 [ k] ; i + + ; str1[i] = \ 0 ;

printf( % s\ n, str1 ) ; 6.5,,,, :,, ;,, : # include stdio.h # include string.h { char str[ 50 ] ; int i, k, num = 0; printf( please input a string! \ n ) ; scanf( % s, str) ; k = strlen( str) ; for (i = 0; i < k/ 2; i + + ) { if( str[ i] = = str[ k - 1 - i] ) num + + ; if( num = = k/ 2 ) printf(! ) ; else printf(! ) ; 6.4 C,,,, 6.6 10 :, ;,,,,,, : # include < stdio.h > { int i, j, mindata, minid; int xx[ 10 ] = {4, 2, 5, 9, 0, 1, 8, 6, 3, 7 ; for(i = 0; i < 9; i + + ) { mindata = xx [i] ;

minid = i; for( j = i + 1; j < 10; j + + ) if( mindata > xx[ j] ) { mindat a = xx[ j] ; minid = j; xx [ minid] = xx [i] ; xx [i] = mindata; for(i = 0; i < 10 ; i + + ) printf( %d, xx[i] ) ; 6.7 10 : :10 10,,,,,, 9, 9 : # include < stdio.h > { int i, j, temp; int xx[ 10 ] = {4, 2, 5, 9, 0, 1, 8, 6, 3, 7 ; for(i = 0; i < 10 ; i + + ) for( j = 0; j < 9 - i; j + + ) / /, if( xx [j] > xx [j + 1 ] ) / / {temp = xx[ j] ; xx[j] = xx[ j + 1 ] ; xx [j + 1 ] = temp; for( j = 0; j < 10; j + + ) printf( a[ % d] = % d\ n, j, xx[j] ) ;,, (, ) C, [ 0, - 1] ( : ),,,,, (,,, n n ) C,,, ( ), \ 0,

\ 0,,,, \0 1., 2., x[ 1 ] [ 2 ] [ 3 ], 6 3. int a[ 12 ] = {1, 4, 7, 10, 2, 5, 8, 11, 3, 6, 9, 12, i = 10;, a[ a [ i] ] 4. char s1 [12] = { string ; char s2 [12] = { string\ n ;, printf ( % d, %d, strlen( s1), strlen( s2 ) ) ; 5. char str [3 ] [ 20 ] = { computer, windows, Unix ;, printf ( % s \ n, str [2 ] ) ;, 6. int a[ ] [4 ] = {5, 6, 8, 7, 2, 4 ;, 7. char str[ ] = { INTEL \ ncpu ;, puts( str) ; ( ) 1. 10,, 2. x [10], Ok, Not Found : 3. x [ 4 ] [4 ],, sum1 sum2, ( ; ) 4., 5. x [4 ] [ 4],, x [0 ] [ 0] x [3 ] [ 3], x[ 0] [1 ] x[ 2] [3 ] 6.,,, 7. 5,

7, C :, :,, 7.1 C, main, C, C C,,,,, C 1, (1 ) C,,,, printf scanf getchar putchar

(2 ),,, 2, (1 ) ( ) (2 ),, 3, (1 ),, (2 ), ( ) ;, ( ), 4 C,,,, 7.2 7.2.1, ANSI C : ( ) { ; ;,,, : 1, 2,,, extern static extern, st atic,, extern

,,,, return ( ) ;, ( ) ( ), return, return ;, void,,, C : ( 1, 2,, n) 1; 2; n ; { ; ;,, 7.1, 4 int max4 (int a, int b, int c, int d) / / { int m1, m2 ; / / if( a > = b ) m1 = a ; / / else m1 = b; if( c > = d) m2 = c; else m2 = d; if( m1 > m2 ) return m1; else return m2; { int x, a1, b1; a1 = 5, b1 = 10 ; x = max4( 12,3 3, a1, b1) ; printf( \ nmax: %d, x) ;, max4 max4,,,,, 4 a b c d, m1 m2

7.2.2 1, : ( ) ;,,,, printf,,,,,,,, ( ),,, : # include < stdio.h > { int x, y = 2000 ; x = printf( H ere: y = % d,, y) ; printf( x = % d\ n, x) ; printf( Do you understand? \ n ) ; : ( ) H ere: y = 2000, x = 10 Do you understand?,, : ( ), int x; int max4(int u, int v, int s, int t ) ; x = max4 (12, 3 3,5,8 ) ; void,, int x; void s ub (int x1, int x2) ; x = sub (2, 3 ) ; : 2 :,, (1 ) ( ),, (2 ),,, (3 ), return; retur n,, return ( ) ;, (

, ) (4 ),, ;, 3, ( ), C,,,,,, 4 : (1 ) : (, ) ; : (, ) ; A NSI C, 7.2,, { float add( float a, float b) ; / / float x, y, z ; printf( \ n input float x, y: ) ; scanf( % f, % f, & x, & y) ; z = add( x, y) ; printf( \ n sum is % f\ n, z) ; float add (float a, float b) { float c ; c = a + b; return c; / / float, float, float add ( float a, float b) ; float add( float, float) ; (2 ) : ( ) ;

ANSI C,,, A NSI C,, 7.3 # include < stdio.h > double area( ) ; { double r; printf( input circle s radius: ) ; scanf( % lf, & r) ; / / printf( the circle s area is % f\ n, area( r) ) ; / / double area( double radius ) { return (3.1415926 radius radius ) ; (3 ) / / area, # include <.h > (4 ),,, : 7.2.3 extern (, ) ;,, C ( C99, int) ;,,, (1 ),, max max4 (2 ),, fwrite, (3 ),,, void void exit,

,,, printf,,, return,, :, ;, void : return ; return ( ) ; void return ( ), retur n 7.4 max 3 { int a, b, c; printf( please input a, b: \ n ) ; scanf( % d, % d, & a, & b ) ; c = max(a, b ) ; printf( max = % d\ n, c) ; a = 16; b = 24; / / printf( max = % d\ n, max( a, b) ) ; / / max (a + b, a b) ; max (int x, int y) { if( x > = y) return ( x) ; else return ( y) ; / /, max, main 3 max max, c; max printf, printf ; max, ( ), max, 7.3,,, 7.3.1 (1 ),,,,,,,

(2 ),,, (3 ),,, C,,, (4 ) C,,, 7.3.2 7.5 void swap(int a, int b) { a = a + b; b = a - b; a = a - b; printf( \ na = % d, b = % d, a, b) ; / / a = 20, b = 10 { int a = 10, b = 20; swap( a, b) ; printf( \ na = % d, b = % d, a, b) ; / / a = 10, b = 20,, swap, a = 20, b = 10, C,,, a 10, b 20, a b, swap, swap a b, 8, ( ) 7.4 C, 7.4.1,, C :, 7.1 main