2009年3月24日 星期二

C語言的範例 –練習函數使用

C語言的範例 –gotoxy()clrscr()應用
題目:學習gotoxy()clrscr()函數
2.程式源代碼: 
#include  
void main(void) 
{ 
clrscr();/*清屏函數*/ 
textbackground(2); 
gotoxy(1, 5);/*定位函數*/ 
cprintf("Output at row 5 column 1\n"); 
textbackground(3); 
gotoxy(20, 10); 
cprintf("Output at row 10 column 20\n"); 
} 
============================================================== 
C語言的範例 練習函數使用
題目:練習函數調用 
1. 程式分析:  
2.程式源代碼: 
#include  
void hello_world(void) 
{ 
printf("Hello, world!\n"); 
} 
void three_hellos(void) 
{ 
int counter; 
for (counter = 1; counter <= 3; counter++) 
hello_world();/*調用此函數*/ 
} 
void main(void) 
{ 
three_hellos();/*調用此函數*/ 
}