untitled

Similar documents
CC213

01

untitled

FY.DOC

untitled

C 1

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

C/C++ - 文件IO

新版 明解C言語入門編

untitled

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

新版 明解C++入門編

untitled

c_cpp

C/C++ - 函数

untitled

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

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

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

nooog

台湾项目书

C

epub 33-8

讀 經 進 度 表 ( : 一 年 讀 經 進 度, : 二 年 讀 經 進 度 ; 完 成 後 請 圈 選 喔! ) Sun Mon Tue 西 1 西 2 西 3 西 4 雅 2 帖 前 1 帖 前 2 雅 3 雅 4 加 1 加 2 加 3 來 7 來

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

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

untitled

春 新 春 年 貨 年 菜 來 這 買 市 場 超 人 氣 美 食 增 添 豐 富 團 圓 好 滋 味 來 臺 北 過 好 年 2 月 4 日 熱 鬧 登 場 盡 情 揪 團 享 受 11 處 商 圈 新 春 採 買 樂 趣 妝 點 花 樣 生 活 花 開 富 貴 過 好 年 最

C C

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

Microsoft Word 年6月號墾汀排版.doc

untitled

第3章.doc

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

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

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

2

chap07.key

C语言的应用.PDF

untitled

华恒家庭网关方案

新・解きながら学ぶJava

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

C/C++ 语言 - 循环

說 明, 成 個 體 統 才 是! 你 痰 迷 了 心, 脂 油 蒙 了 竅, 國 孝 家 孝 兩 重 在 身, 就 把 個 人 送 來 了 這 會 子 被 人 家 告 我 們, 我 又 是 個 沒 腳 蟹, 連 官 場 中 都 知 道 我 利 害 吃 醋, 如 今 指 名 提 我, 要 休 我,

C/C++ - 数组与指针

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

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

3.1 num = 3 ch = 'C' 2

untitled

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

Microsoft Word - 第3章.doc

并行计算

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

Instruction_8723_8725_8729

C

(Microsoft Word \246~\253\327\276\307\256\325\263\370\247i_\252k\271\316\256\325\270\263\267|\263q\271L_ _)

Microsoft Word _ doc

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++;

CHAPTER VC#

Microsoft Word - 01.DOC

untitled

extend

[改訂新版]C言語による標準アルゴリズム事典

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

目 錄 壹 緣 起 P.3 一 與 緬 甸 僑 生 結 緣 3 二 2015 緬 甸 再 見 家 鄉 服 務 隊 團 員 名 單 三 團 隊 的 服 務 理 念 四 團 隊 精 神 運 作 與 訓 練 五 海 外 服 務 內 容 與 運 作 模 式 5 貳 年 度 服 務 目 的 P.8

第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

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

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

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

bingdian001.com

1

untitled

02

C++ 程序设计 告别 OJ1 - 参考答案 MASTER 2019 年 5 月 3 日 1

untitled

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

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

static struct file_operations gpio_ctl_fops={ ioctl: gpio_ctl_ioctl, open : gpio_open, release: gpio_release, ; #defineled1_on() (GPBDAT &= ~0x1) #def

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("%

CHAPTER 1

download.kaoyan.com_2006ÄêÌì½ò¹¤Òµ´óѧ¸ß¼¶ÓïÑÔ³ÌÐòÉè¼Æ£¨409£©¿¼ÑÐÊÔÌâ

第7章-并行计算.ppt

Chapter12 Derived Classes

Ps22Pdf

obj-c_4.key

NOWOER.OM m/n m/=n m/n m%=n m%n m%=n m%n m/=n 4. enum string x1, x2, x3=10, x4, x5, x; 函数外部问 x 等于什么? 随机值 5. unsigned char *p1; unsigned long *p

Microsoft Word - Index.doc

ebook15-10

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

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

2008年4月全国计算机等级考试二级C语言真题(含答案)

C

Microsoft Word cppFinalSolution.doc

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

立 志 于 打 造 最 贴 近 考 生 实 际 的 辅 导 书 计 算 机 考 研 之 数 据 结 构 高 分 笔 记 率 辉 编 著 周 伟 张 浩 审 核 讨 论 群 :

untitled

Generated by Unregistered Batch DOC TO PDF Converter , please register! 浙江大学 C 程序设计及实验 试题卷 学年春季学期考试时间 : 2003 年 6 月 20 日上午 8:3

Transcription:

A, 3+A printf( ABCDEF ) 3+ printf( ABCDEF )

2.1 C++

main main main)

* ( ) ( ) [ ].* ->* ()[] [][] ** *&

char (f)(int); ( ) (f) (f) f (int) f int char f char f(int) (f)

char (*f)(int); (*f) (int) ( ) (*f) (int) f int char

char *f(int); * (int) f(int) * f int char

C C++ int (*(**f)[10])(int, int); ** *f **f (**f) ( ) **f[10] f[10]

typedef typedef int (*F[10])(int, int); F *f; F *f f F F *f F *f int (*(*f)[10])(int, int); (int (*(*)[10])(int, int)) x

2.5 void * void main(void){ int p; float q, *m=&q; void *r=&p; *r=345; // : *(int *)r=345; // p=345 *(int *)r=3.14; // p=3 r=m; // void * *r=3.14; // : *(float *)r=3; // q=3.00 *(float *)r=3.14;// q=3.14 }

const, C++ #define

2.7 void main(void){ const char *ptc; // char * const cp="const pointer";// const char *const cptc="cstptc";// ptc="pointer to constant"; // *ptc='p'; // *ptc const char cp="const ptr"; // cp const *cp= Array of char [0]; //*cp char *cp='a' cptc="const to const ptr"; // cptc const *cptc='c'; // *cptr const char }

2.8

enum int =0 1 enum WEEKDAY {Sun, Mon, Tue, Wed, Thu, Fri, Sat}; typedef int WEEKDAY; const int Sun=0, Mon=1, Tue=2 const int Wed=3, Thu=4, Fri=5, Sat=6; WEEKDAY w1=sun w2(mon);// w2=mon enum WK {Su=-2, Mo, Tu, We, Th, Fr =1, Sa}; //We=1

volatile ( ) const volatile int y=3; volatile int x; x=3; if(x==4) cout<<"x changed by other routines"; 2.9 int1c main number main number

& ( ) ( ) ( ) C++

swap(int *x, int *y){ int t=*x; *x=*y; *y=t; } // swap(int&x, int&y){ int t=x; x=y; y=t; } //

2.11 #include <iostream.h> int strint(const char *str, int &val) { char c; //str val=0; while(c=*str++) // str if((c>='0')&&(c<='9')) val=val*10+c-'0'; else return 0; return 1; }

void main(int argc, char *argv[ ]) { int i, n; for(i=1; i<argc; i++) if(strint(argv[i], n))cout<<"argv["<<i<<"]="<<n<<"\n"; else cout<<"argument "<<i<<" is not a decimal"; }

2.12 ++ int inc(int &x) { return x++; } int i=1, j; char c=1; void main(void){ // j=inc(i); //i=2, j=1 i j=inc(++i); //i=4, j=3 i j=inc(i++); //i=5, j=4 i j=inc(i+5); //i=5, j=10 i j=inc(c); //c=1, j=1 c j=inc(++c); //c=2, j=2 c j=inc(c++); //c=3, j=2 c j=inc(c+5); //c=3, j=8 c } // c char int int &x

2.13 int i; // i=0 const int &j=2;// int &x=++i; //++i i int &y=i=0; //i=0 i int &z=y=3; //y=3 i int &f(int &v){ return v+=5;}// v void main(void){ int i=0;

const int k=10, &j=k; const int &m=2;// 2 ( ) const int &n=i; // int &x=i++; // int &y=++++i; //++++i y i int &z=i=4; //i=4 z i int &r=z=8; //z=8 r i i=3; //r=y=z=i=3 x=0 x=6; //x=6 r=y=z=i=3 r=12; //r=y=z=i=12 x=6 ++y=10; // ++y i 10 i r=y=z=i=10 (z=10)=15; // z=10 i 15 i r=y=z=i=15 (f(r)=1)=2; //f(r) r i (i=1) r=y=z=i=2 }

2.14 #include <stdio.h> char *&weekday(int &day){ static char *week[7]={"sun","man","the","wed","thu","fri","sat"}; return week[day++]; } void main(void){ int day=0; printf(weekday(day)); // Sun day=1 weekday(day)="mon"; // week[1] "Mon, day=2 weekday(day)[1]='u'; // "The" "Tue" day=3 printf(weekday(day+2));//day+2,,day=3 printf(weekday(day=0)); // Sun day=1 }

2.16 struct A{ int i:3; int j:4; int k; } a; int j(0); //C++ j=0 int &k=j++; //

void main(void){ register int i=0, &j=i;//i, j int &&m=j; // j int &*m; // int &s[4]; // int t[6], (&u)[6]=t;// u t int &v=t[0]; // v int &w=a.j; // int &x=a.k; //a.k }

C C++ overload call

2.7 #include <dos.h> #include <iostream.h> overload GetTime; // long GetTime(void){...} long GetTime(int &hours, int &minutes, int &seconds){...} void main(void){ int h, m, s; cout<<"now is "<<GetTime(h, m, s) cout<<" seconds from midnight,"; cout<<"or "<<h<<":"<<m<<":"<<s<<"\n"; }

: int printf(const char *format, ); long sum(int n,...){ long s=0; int *p=&n+1; for (int k=0; k<n; k++) s+=p[k]; return s; } void main( ){ int a=4; long s=sum(3,a,2,3); }

2.20 #include <conio.h> #include <stdio.h> intsayatxy(char*msg, intx=1, inty=1){ gotoxy(x, y); // x y return printf(msg); // msg } void main(void){ sayatxy("default"); // (1,1) Default sayatxy("default Line", 30);// (30,1) Default Line sayatxy("specified",1,2); // (1,2) Specified }

2.21 error( System A ) error(char *sys, char*msg="undefined error\n") error(char *sys, int code=0) error(char *sys, ) error(char *sys)

( ) ( ) 10 100 5 100*10+5=1005 20 100*10+20=1020 inline 5 100*5=500 20 100*20=3000

2.22 #include <iostream.h> inline double area(double r){ return 3.1415926*r*r; } void main(void){ double m; 3.1415926*m*m call area cout<<"please input a radius:"; cin>>m; cout<<"the area is "<<area(m); }

if, switch,while, for,do while,? :, static main main

A.CPP extern int f( ); int main( ){ return f( ); } B.CPP inline static int main( ) { return 3; } //static int f( ){ return main( ); } A.cpp B.cpp M.exe main A.cpp