我想力利用turbo c 寫一ㄍ有關霹靂燈ㄉ程式...例如:畫面已做好..我該如何讓跑馬燈..能依序亮下去...請各位大大提供ㄍ程式
2006-08-05 10:14:35 · 5 個解答 · 發問者 明鋒 1 in 電腦與網際網路 ➔ 程式設計
假設一個符號,要往畫面的右邊走10次,然後在往回走,該如何寫?
2006-08-05 10:36:46 · update #1
提供我以前在補習班教C時的範例
這個跑馬燈程式會在螢幕中間秀一段指定文字
您參考參考
#define ShowLen 14
#include
#include
#include
int run( char * );
int run( char *str ){
int i, count, sl;
char *pointer;
clrscr();
pointer = (char *) malloc( 120 );
if( pointer==NULL ) exit(1);
sl = strlen( str );
i = 0;
do
{
strcpy( pointer, str+i );
if( i>(sl-ShowLen) ) strcat( pointer, str );
pointer[ ShowLen ] = '\0';
gotoxy( 34, 10 );
printf( pointer );
delay( 250 );
if( ++i>=sl ) i = 0;
} while( ! kbhit() );
}
int main( int argc, char *argv[] ) {
char *str;
int i, total_len;
if( argc>1 ) {
total_len = 0;
for( i=1; i
if( str==NULL ) {
printf( "\n\tNo memory error!\a\n" );
exit( 2 );
}
total_len = 0;
for( i=1; i
total_len += strlen( argv[ i ] ) + 1;
}
sprintf( str+total_len-1, ". " );
}
else str = ">>>>> What a wonderful world!.... ";
run( str );
gotoxy( 1, 22 );
}
2006-08-05 13:13:31 · answer #1 · answered by 暗黑歐吉尚 3 · 0⤊ 0⤋
認同 Danny
題目既然指名是 Turbo C, 在 conio.h 裡有 goto(x,y), 用它,最好了!
2006-08-05 19:52:23 · answer #2 · answered by ? 7 · 0⤊ 0⤋
回補充的..
你可以用一個 count 變數來記錄是否超過 10
用 gotoxy(x, y) 函式來返回..
ps: 這是 Turbo C/C++ 才有的函式
2006-08-05 12:27:58 · answer #3 · answered by 榮章 4 · 0⤊ 0⤋
可否給個範例程式
2006-08-05 10:58:30 · answer #4 · answered by 明鋒 1 · 0⤊ 0⤋
較簡單的 在ascii code 裡有個倒退鍵 的code由左往右 倒退一格 印 空白+亮由右往左 倒退兩格 印 亮啊如果你有裝 ansi.sys 的話 ,就用 ansi 的控制碼就可以很漂亮的秀圖可以指定xy 清除 指定xy 印出,不過要k資料 已經很少人在用
2006-08-05 10:46:08 · answer #5 · answered by ? 5 · 0⤊ 0⤋