# Void swap0 (int x, int y){ int t; t = x; x = y; y = t; } void swap (int *x, int *y){ int t; t = *x; *x = *y; *y = t; } a10 b20 main(){ int a=10, b=20;

## Presentation on theme: "Void swap0 (int x, int y){ int t; t = x; x = y; y = t; } void swap (int *x, int *y){ int t; t = *x; *x = *y; *y = t; } a10 b20 main(){ int a=10, b=20;"— Presentation transcript:

void swap0 (int x, int y){ int t; t = x; x = y; y = t; } void swap (int *x, int *y){ int t; t = *x; *x = *y; *y = t; } a10 b20 main(){ int a=10, b=20; swap0 (a,b); printf("a=%i, b=%i\n", a,b); swap (&a, &b); printf("a=%i, b=%i\n", a,b); } 1 a=10, b=20 a=20, b=10 Call by Value 按值調用 Call by Reference 按址調用 xyxy stack t10 20 10 x=10, y=20 stack x10 y20 t10 x=address *x=value http://www.ablmcc.edu.hk/~scy/home/javascript/function.htm

void drawLine (char c, int n){ int i; for (i=0; i { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/3894057/slides/slide_2.jpg", "name": "void drawLine (char c, int n){ int i; for (i=0; i

main(){ char name[50]="chan tai man, joseph"; allUpper(name); } void allUpper (char s[]){ int i; for (i=0; i { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/13/3894057/slides/slide_3.jpg", "name": "main(){ char name[50]= chan tai man, joseph ; allUpper(name); } void allUpper (char s[]){ int i; for (i=0; i

int sumN (int n){ if(n<=0) return 0; return n+sumN(n-1); } stack n7 n8 n9 n10 main(){ int a=10, b=20, c=30; c = sumN (a); printf("c=%i\n", c); } 5 a10 b20

Download ppt "Void swap0 (int x, int y){ int t; t = x; x = y; y = t; } void swap (int *x, int *y){ int t; t = *x; *x = *y; *y = t; } a10 b20 main(){ int a=10, b=20;"

Similar presentations