本文目錄一覽:
- 1、C語言的一個笑臉編程!求大神!
- 2、C語言編程:一個運動中的笑臉(C語言高手進)
- 3、c語言編寫移動笑臉
- 4、求c語言笑臉可自由上下左右動的代碼
- 5、用c語言輸出哭臉表情~直接要代碼~
- 6、如何用c語言編寫一個程序,輸出一張笑臉
C語言的一個笑臉編程!求大神!
#include stdio.h
#include stdlib.h
void main(void)
{
FILE *fp1 = NULL, *fp2=NULL;
char ch = ‘ ‘;
long n=0;
if ( ( fp1 = fopen(“test.txt”,”r”) ) == NULL )
{
printf(“fail to open file \”test.txt\” press any key to exit!\n”);
getchar();
exit(0);
}
if ( ( fp2 = fopen(“result.txt”,”w”) ) == NULL )
{
printf(“fail to creat file \”test.txt\” press any key to exit!\n”);
getchar();
exit(0);
}
fseek(fp1,-1L,SEEK_END);
n=ftell(fp1)+1;
ch=fgetc(fp1);
while ( n )
{
fputc(ch,fp2);
fseek(fp1,-2L,SEEK_CUR);
n–;
ch=fgetc(fp1);
}
fclose(fp1);
fclose(fp2);
printf(“done!\n”);
getchar();
}
VC++6.0上測試通過!注意文件test.txt要自己建立,並和這個可執行程序放在同一目錄下!
C語言編程:一個運動中的笑臉(C語言高手進)
原因比較簡單,因為只打印了一個笑臉,所以它不會動
#includestdio.h
#includeconio.h
struct move_point
{
int x,y;
int xv,yv;
}man; /*定義了一個叫man的結構體變量,x,y,xv,yv默認是0!如果要讓它動的話,至少要給xv,yv中一個賦值*/
int main()
{
/**************************************************/
gotoxy(man.x,man.y); /*移動坐標到man.x,man.y*/
printf(” “); /*打印空格(用於蓋住原來的字符)*/
man.x+=man.xv;
man.y+=man.yv; /*這兩句用來移動光標前的計算*/
gotoxy(man.x,man.y); /*移動光標*/
printf(“%c\b”, 2); /*打印笑臉(ASCII碼2)*/
/**************************************************/
getch(); /*暫停下*/
return 0;
}
想要讓笑臉動,除了上面的賦值,還要把上面的一大堆星號之間的部分用循環套起來,再加上延遲的語句(防止刷新太快,看不清)就可以了.
c語言編寫移動笑臉
#includestdio.h
#includetime.h
#includestring.h
void main()
{
char a[50];
int flag,i=0;
double time,k,temp=0;
memset(a,1,sizeof(a));
a[19]=’\0′;
while(1)
{
time=(double)clock()/CLOCKS_PER_SEC;
flag=(int)(time*100); //兩位時間 例如:12 13 14 無論幾位 最高位為秒
k=flag/10; //在兩位的前提下 除以5每0.5秒 走一步,若除以10 則1秒走一步
if(temp!=k)
{
for(flag=0;flagi;flag++)
printf(” “); //步長
printf(“%s\r”,a);
i++;
temp=k;
}
if(i==62) break;
}
}
求c語言笑臉可自由上下左右動的代碼
挺有意思的一道題目,看一下這樣符不符合要求,用wasd控制移動。在VC6運行過了。
#includestdio.h
#includestdlib.h
#includeconio.h
int main()
{
//牆從第2行第2列到第15行第15列
int lines = 2 , rows = 2 , i ;
char operate ;
do{
system( “cls” ) ; //清屏函數
switch( operate )
{
case ‘w’ : //上移
if( lines == 2 )
printf(“不能再往上走了”) ; //到邊界後不能再往上
else
lines — ; //行減
break ;
case ‘s’ : //下移
if( lines == 15 )
printf(“不能再往下走了”) ; //到邊界後不能再往下
else
lines ++ ; //行增
break ;
case ‘a’ : //左移
if( rows == 2 )
printf(“不能再往左走了”) ; //到邊界後不能再往左
else
rows — ; //列減
break ;
case ‘d’ : //右移
if( rows == 15 )
printf(“不能再往右走了”) ; //到邊界後不能再往右
else
rows ++ ; //列增
break;
default :
break ;
}
//根據行列值,輸出 lines-1 個換行,rows-1 個空格
for( i = 1 ; i lines ; i ++ )
printf( “\n” ) ;
printf( “%*c” , rows , 1 ) ;
} while( operate = getch( ) ) ;
return 0 ;
}
用c語言輸出哭臉表情~直接要代碼~
#includestdio.h
void main()
{
printf(“%c\n”,01);//笑臉
printf(“%c\n”,02);//哭臉
}
如何用c語言編寫一個程序,輸出一張笑臉
你好
下面是很簡單的顯示程序
沒有使用任何高級語法 樓主應該能看懂
#include stdio.h
int main(void)
{
printf(” * * * * *\n”
” * *\n”
” * ^ ^ *\n”
“* *\n”
“* *\n”
“* *\n”
” * ___ *\n”
” * *\n”
” * * * * *\n”);
return 0;
}
希望能幫助你哈
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/236995.html