提示:在C中使用延迟 [英] TIP: Using a delay in C
问题描述
在C中使用延迟,使用Linux。 gcc-3.3
这个程序让一个男孩骑着自行车跑在屏幕上。 :D
很高兴看到游戏和延迟C.
#include< stdio.h>
int branco (int j){
int k;
for(k = 0; k< j; k ++)
{
printf("");
}
}
int main(){
int i;
for(i = 0; i< 20; i ++)
{
// limpa a tela
printf(" \ 033 [H\ 033 [2J"];
usleep(50000);
branco(i);
printf(" __ @ \ n");
branco(i);
printf(" _` \\\ \\<,_ \ n");
branco(i);
printf("(*)/(*)\ n"); < br $>
}
}
Using a delay in C, using Linux. gcc-3.3
This program do a boy in a bike runing in the screen. :D
Its cool to see about games and delay in C.
#include<stdio.h>
int branco(int j){
int k;
for (k=0;k<j;k++)
{
printf(" ");
}
}
int main(){
int i;
for(i=0;i<20;i++)
{
//limpa a tela
printf("\033[H\033[2J");
usleep(50000);
branco(i);
printf(" __@\n");
branco(i);
printf(" _`\\<,_\n");
branco(i);
printf(" (*)/ (*)\n");
}
}
推荐答案
" silveira neto" < OT ********** @ yahoo.com.br>在留言中写道
新闻:是****************************** @ localhost.ta lkaboutprogramming。 com ...
"silveira neto" <ot**********@yahoo.com.br> wrote in message
news:be******************************@localhost.ta lkaboutprogramming.com...
在C中使用延迟,使用Linux。 gcc-3.3
这个程序让一个男孩骑着自行车跑在屏幕上。 :D
很酷的看到游戏和延迟C.
你下面的内容不是(标准)C。
#include< ; stdio.h>
int branco(int j){
int k;
for(k = 0; k< j; k ++)
{
printf( ";
}
int main(){
int i;
for(i = 0; i< 20; i ++)
// limpa a tela
printf(" \ 033 [H [033 [2J]);
''printf()''的这个字符串参数取决于标准
输入设备以特定方式解释它。根本不便携。
usleep(50000);
标准C中没有此类功能。
branco(i);
printf(" __ @ \ n");
branco(i);
printf(" _` \\<,_ \ n");
branco(i);
printf("(* )/(*)\ n");
}
返回0; / * C89必备,C99可选*
}
Using a delay in C, using Linux. gcc-3.3
This program do a boy in a bike runing in the screen. :D
Its cool to see about games and delay in C.
What you have below is not (standard) C.
#include<stdio.h>
int branco(int j){
int k;
for (k=0;k<j;k++)
{
printf(" ");
}
}
int main(){
int i;
for(i=0;i<20;i++)
{
//limpa a tela
printf("\033[H\033[2J");
This string argument to ''printf()'' depends upon the standard
input device interpreting it a particular way. Not portable at all.
usleep(50000);
No such function in standard C.
branco(i);
printf(" __@\n");
branco(i);
printf(" _`\\<,_\n");
branco(i);
printf(" (*)/ (*)\n");
}
return 0; /* mandatory for C89, optional for C99 */
}
'可爱''小程序仅限数量有限
平台/配置。
-Mike
A ''cute'' little program only usable on a limited number
of platforms/configurations.
-Mike
> expand delay.c
#include< stdio.h>
#include< stdlib.h>
void branco(int j){
for(int k = 0; k< j; ++ k){
printf("");
}
}
int main(int argc,char * argv []){
extern int usleep(unsigned long usec);
for(int i = 0; i< 20; ++ i){
// limpa a tela
printf(" \ 033 [H\ 033 [2J"];
usleep(50000);
branco(i);
printf(" __ @ \ n");
branco(i);
printf(" _` \\<,_ \ n");
branco(i);
printf("(*)/(*)\ n");
}
返回EXIT_SUCCESS;
}
> expand delay.c
#include<stdio.h>
#include<stdlib.h>
void branco(int j) {
for (int k = 0; k < j; ++k) {
printf(" ");
}
}
int main(int argc, char* argv[]) {
extern int usleep(unsigned long usec);
for(int i = 0; i < 20; ++i) {
//limpa a tela
printf("\033[H\033[2J");
usleep(50000);
branco(i);
printf(" __@\n");
branco(i);
printf(" _`\\<,_\n");
branco(i);
printf(" (*)/ (*)\n");
}
return EXIT_SUCCESS;
}
" silveira neto" < OT ********** @ yahoo.com.br>在留言中写道
新闻:是****************************** @ localhost.ta lkaboutprogramming。 com ...
"silveira neto" <ot**********@yahoo.com.br> wrote in message
news:be******************************@localhost.ta lkaboutprogramming.com...
在C中使用延迟,使用Linux。 gcc-3.3
这个小组是关于ISO C的,即在_all_
平台上编译和运行的程序,而不仅仅是使用GNU C的Linux。
这个程序让一个男孩骑着自行车跑在屏幕上。 :D
很酷的看到游戏和延迟C.
请将这些unix特定的提示发布到unix特定群组。
< snip>
Using a delay in C, using Linux. gcc-3.3
This group is about ISO C, i.e. programs which compile and run on _all_
platforms, not just Linux using GNU C.
This program do a boy in a bike runing in the screen. :D
Its cool to see about games and delay in C.
Please post such unix specific ''tips'' to unix specific groups.
<snip>
接近ISO C等价物就像......
#include< stdio.h>
#include< time.h>
void usleep(unsigned long u)
{
clock_t end,start = clock();
if(start ==(clock_t)-1)return;
end = start + CLOCKS_PER_SEC * (u / 1000000.0);
while(clock()!= end);
}
int main(void)
{
int i;
for(i = 0; i< 20; i ++)
{
usleep(500000);
put(" \\\\\\\\\\\\ \\ n \ n \\\\\\\\\\\\\\\ ;);
put(&\\; \\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\ \ n \\ nn;);
printf("%* s \ n",10 + i * 2," __ @");
printf(%* s \ n,10 + i * 2," _` \\<,_");
printf("%* s \ n",10 + i * 2,"(*)/(*)" );
}
返回0;
}
-
彼得
A near ISO C equivalent would be something like...
#include <stdio.h>
#include <time.h>
void usleep(unsigned long u)
{
clock_t end, start = clock();
if (start == (clock_t) -1) return;
end = start + CLOCKS_PER_SEC * (u / 1000000.0);
while (clock() != end) ;
}
int main(void)
{
int i;
for (i = 0; i < 20; i++)
{
usleep(500000);
puts("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n");
puts("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n");
printf("%*s\n", 10 + i * 2, " __@ ");
printf("%*s\n", 10 + i * 2, " _`\\<,_");
printf("%*s\n", 10 + i * 2, "(*)/ (*) ");
}
return 0;
}
--
Peter
这篇关于提示:在C中使用延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!