A. 一個c語言惡搞程序
#include<stdio.h>
#include<string.h>//
intmain(void)
{
charch[8];
printf("請輸入您的名字拼音,我可以算出你的智商哦!");
while(1)//
{
scanf("%s",ch);//
if(!strcmp(ch,"langtian"))//
{
printf("真是個大帥哥啊,智商達1000 ");
}else{
printf("豬頭嗎? 豬頭呀! ");
}
}
return0;
}
B. 求一些惡搞程序的C語言源代碼
#include "stdio.h"
#include "stdlib.h"
result love(boy, girl)
{
if ( boy.有房() and boy.有車() )
{
boy.set(nothing);
return girl.嫁給(boy);
}
if ( girl.願意等() )
{
while( ! (boy.賺錢 > 100,000 and girl.感情 > 8 ) )
{
for ( day=1; day <=365; day++)
{
if ( day == 情人節 )
if ( boy.givegirl(玫瑰) )
girl.感情++;
else
girl.感情--;
if( day == girl.生日)
if ( boy.givegirl(玫瑰) )
girl.感情++;
else
girl.感情--;
boy.拚命賺錢();
}
}
if ( boy.有房() and boy.有車() )
{
boy.set(nothing);
return girl.嫁給(boy);
}
年齡++;
girl.感情--;
}
return girl.goto( another_boy);
}
C. 求C語言編寫的表白程序,要代碼
呃,你還不如用vbs,網上也有一堆教程和例子,很簡單,隨便看一下就知道怎麼寫了。
DimmyName,herName,myNameAns,herNameAns
myName="池早早"
herName="歐浩辰"
MsgBox(herName+",我喜歡你!我的腦和心,我全身上下每一個器官都在說著我喜歡你。")
do
herNameAns=InputBox("我喜歡誰?","某人的名字")
loopwhileherNameAns<>herName
do
myNameAns=InputBox("誰喜歡"+herName+"?","某人的名字")
loopwhilemyNameAns<>myName
do
myNameAns=InputBox("大聲點我聽不見!","你的名字")
loopwhilemyNameAns<>myName
MsgBox(herName+",這是我為你准備的葯,你趁熱吃吧!")
.........................保存為xxx.vbs文件就能運行了
D. 求幾個比較有趣,簡單的C語言源代碼 小白自己敲著練一下手感
最簡單的模擬計時器:
#include<stdio.h>
#include<conio.h>
#include<windows.h>
int m=0,s=0,ms=0; //m是分 s是秒 ms是毫秒
//以下是5個自編函數
void csh( ); //初始化界面
void yinc(int x,int y); //隱藏游標的函數(y值設為0就會隱藏)
void jishi( ); //計時器運行(每100毫秒變化一次)
void Color (short x, short y); //設定顏色的函數(y設為0就是黑底)
void gtxy (int x, int y); //控制游標位置的函數
int main( ) //主函數
{ csh( );
getch( );
while(1)
{ jishi( );
Sleep(100); //間隔100毫秒
if( kbhit( ) )break; //有鍵按下就退出循環
}
return 0;
}
void csh( ) //初始化界面
{Color(14,0); //設定淡黃字配黑底
printf(「 計時器」);
Color(10,0); //設定淡綠字配黑底
printf(" ┌───────────┐");
printf(" │ │");
printf(" └───────────┘");
gtxy(10,4); //游標到屏幕第10列4行處輸出
Color(7,0); //恢復白字黑底
printf(" 00:00:00 ");
yinc(1,0 ); //隱藏游標(yinc代表隱藏)
return;
}
void jishi( ) //計時器運行
{ms+=1;
if(ms==10){s+=1;ms=0;}
if(s==60){m+=1;s=0;}
gtxy(10,4);
Color(9,0); //設定淡藍字配黑底
if(m>9) printf(" %d:",m);
else printf(" 0%d:",m);
Color(14,0); //設定淡黃字配黑底
if(s>9) printf("%d:",s);
else printf("0%d:",s);
Color(12,0); //設定淡紅字配黑底
printf("0%d",ms);
}
void gtxy (int x, int y) //控制游標位置的函數
{ COORD pos;
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition ( GetStdHandle (STD_OUTPUT_HANDLE), pos );
}
void Color (short ForeColor= 7, short BackGroundColor= 0) //設定顏色的函數
{ HANDLE handle = GetStdHandle ( STD_OUTPUT_HANDLE );
SetConsoleTextAttribute ( handle, ForeColor + BackGroundColor * 0x10 );
}
void yinc(int x,int y) //隱藏游標的設置(gb代表游標)
{ CONSOLE_CURSOR_INFO gb={x,y}; //x為1-100,y為0就隱藏游標
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &gb);
}
E. 求助啊,誰有有趣的c語言小程序,並且要有源代碼!!
一個貪吃蛇C源代碼,本人稍加優化,練手應當不錯。
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <time.h>
#include <Windows.h>
#define WIDTH 78 //地圖的寬,x軸
#define HEIGHT 26 //地圖的高,y軸
int dire=3; //方向變數,初值為向「左」
int Flag=0; //判斷是否吃了食物的標志
int score=0; //玩家得分
struct foods{ int x;
int y;
}food; //結構體food有2個成員
struct snakes{int len;
int speed;
int x[100];
int y[100];
}snake; //結構體snake有4個成員
void gotoxy( int x,int y) //獲得句柄,才能控制游標移動
{ COORD coord;
coord.X=x;
coord.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void gotoxy( int x,int y); //以下聲明要用到的幾個自編函數
void csh( );
void keyDown( );
void Move( );
void putFood( );
int pdOver( );
int main( ) //主函數
{ csh( );
while(1)
{ keyDown( );
Move( );
putFood( );
if(pdOver( ))
{system(「cls」);
gotoxy(WIDTH/2+1,HEIGHT/2);
printf(「游戲結束!T__T」);
gotoxy(WIDTH/2+1,HEIGHT/2+1);
printf(「玩家總分:%d分」,score);
getch( );
break; }
Sleep(snake.speed);
}
return 0;
}
void csh( ) //初始化界面
{ int i;
gotoxy(0,0);
CONSOLE_CURSOR_INFO cursor_info={1,0}; //游標值設為0就隱藏了
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
for(i=0;i<=WIDTH;i=i+2) //橫坐標要為偶數,因為這里要列印的字元佔2個位置
{ gotoxy(i,0); //列印上邊框
printf("■");
gotoxy(i,HEIGHT); //列印下邊框
printf("■");
}
for(i=1;i<HEIGHT;i++)
{ gotoxy(0,i); //列印左邊框
printf("■");
gotoxy(WIDTH,i); //列印右邊框
printf("■");
}
while(1)
{ srand((unsigned int)time(NULL)); //設定種子為當前時間
food.x=rand()%(WIDTH-4)+2;
food.y=rand()%(HEIGHT-2)+1;
if(food.x%2==0)break;
}
gotoxy(food.x,food.y); //到食物坐標處列印初試食物
printf("●");
snake.len=3; //蛇身長
snake.speed=350; //刷新蛇的時間,即是移動速度
snake.x[0]=WIDTH/2+1; //蛇頭橫坐標為偶數
snake.y[0]=HEIGHT/2; //蛇頭縱坐標
gotoxy(snake.x[0], snake.y[0]); //列印蛇頭
printf("■");
for(i=1;i<snake.len;i++)
{ snake.x[i]=snake.x[i-1]+2;
snake.y[i]=snake.y[i-1];
gotoxy(snake.x[i],snake.y[i]); //列印蛇身
printf("■");
}
return;
}
void keyDown( ) //按鍵操作
{ int key;
if(kbhit( )) //如有按鍵輸入才執行下面操作
{ key=getch( );
if(key==224) //值為224表示按下了方向鍵,下面要再次獲取鍵值
{ key=getch( );
if(key==72&&dire!=2)dire=1; //72為向上
if(key==80&&dire!=1)dire=2; //80為向下
if(key==75&&dire!=4)dire=3; //75為向左
if(key==77&&dire!=3)dire=4; //77為向右
}
if(key==13)
{ while(1) if((key=getch( ))==13) break; } //13為回車鍵,這兒用來暫停
}
}
void Move( ) //蛇移動一節
{ if(Flag==0) //如沒吃食物,才執行下面操作擦掉蛇尾
{ gotoxy(snake.x[snake.len-1],snake.y[snake.len-1]);
printf(" ");
}
int i;
for (i = snake.len - 1; i > 0; i--) //從蛇尾起每節存儲前一節坐標值(蛇頭除外)
{ snake.x[i]=snake.x[i-1];
snake.y[i]=snake.y[i-1];
}
switch (dire) //以下判斷蛇頭該往哪個方向移動,並獲取最新坐標值
{ case 1: snake.y[0]--; break;
case 2: snake.y[0]++; break;
case 3: snake.x[0]-=2; break;
case 4: snake.x[0]+=2; break;
}
gotoxy(snake.x[0], snake.y[0]); //列印蛇頭
printf("■");
if (snake.x[0] == food.x && snake.y[0] == food.y) //如吃到食物執行以下操作
{ snake.len++; score += 50; snake.speed -= 5; Flag = 1;}
else Flag = 0;
if(snake.speed<160) snake.speed= snake.speed+5; //作弊碼,不讓速度無限加快
}
void putFood( ) //投放食物
{ if(Flag == 1) //如吃到食物才執行以下操作,生成另一個食物
{ while (1)
{ int i,n= 1;
srand((unsigned int)time(NULL)); //設定當前時間,接下產生食物坐標值
food.x = rand( ) % (WIDTH - 4) + 2;
food.y = rand( ) % (HEIGHT - 2) + 1;
for (i = 0; i < snake.len; i++) //隨機生成的食物不能在蛇的身體上
{ if (food.x == snake.x[i] &&food.y == snake.y[i])
{ n= 0; break;}
}
if (n && food.x % 2 == 0) break; //n不為0且橫坐標為偶數,食物坐標取值成功
}
gotoxy(food.x, food.y); //游標到取得的坐標處列印食物
printf("●");
}
return;
}
int pdOver( ) //判斷游戲是否結束
{ int i;
gotoxy(2,HEIGHT+1); //以下列印一些其它信息
printf(「暫停鍵:Enter.」);
gotoxy(2,HEIGHT+2);
printf(「游戲得分:%d」,score);
if (snake.x[0] == 0 || snake.x[0] == WIDTH) return 1; //蛇頭觸碰左右邊界
if (snake.y[0] == 0 || snake.y[0] == HEIGHT) return 1; //蛇頭觸碰上下邊界
for (i = 1; i < snake.len; i++)
{ if (snake.x[0] == snake.x[i] && snake.y[0] == snake.y[i]) return 1; } //蛇頭觸碰自身
return 0;
}
F. 哪位大神有c語言做的小人的代碼,什麼小人都可以,什麼叮當貓hellokitty
#include<stdio.h>
intmain(){
char*s[]={"______________$$$$$$$",
"_____________$$$$$$$$$",
"____________$$$$$$$$$$$",
"____________$$$$$$$$$$$",
"____________$$$$$$$$$$$",
"_____________$$$$$$$$$",
"_____$$$$$$_____$$$$$$$$$$",
"____$$$$$$$$__$$$$$$_____$$$",
"___$$$$$$$$$$$$$$$$_________$",
"___$$$$$$$$$$$$$$$$______$__$",
"___$$$$$$$$$$$$$$$$_____$$$_$",
"___$$$$$$$$$$$__________$$$_$_____$$",
"____$$$$$$$$$____________$$_$$$$_$$$$",
"______$$$__$$__$$$______________$$$$",
"___________$$____$_______________$",
"____________$$____$______________$",
"_____________$$___$$$__________$$",
"_______________$$$_$$$$$$_$$$$$",
"________________$$____$$_$$$$$",
"_______________$$$$$___$$$$$$$$$$",
"_______________$$$$$$$$$$$$$$$$$$$$",
"_______________$$_$$$$$$$$$$$$$$__$$",
"_______________$$__$$$$$$$$$$$___$_$",
"______________$$$__$___$$$______$$$$",
"______________$$$_$__________$$_$$$$",
"______________$$$$$_________$$$$_$_$",
"_______________$$$$__________$$$__$$",
"_____$$$$_________$________________$",
"___$$$___$$______$$$_____________$$",
"__$___$$__$$_____$__$$$_____$$__$$",
"_$$____$___$_______$$$$$$$$$$$$$",
"_$_____$____$_____$$$$$$__$$$$$$$$"};
intLENGTH=32;
inti=0;
for(i=0;i<LENGTH;i++){
printf("%s ",s[i]);
}
}
G. 求一段整人C語言小程序
給你最簡單的,那有時間編那個,這個文件是批處理,打開記事本,輸入第一行@echo off,第二行 start cmd,第三行,%0然後保存成文件類型為bat文件。然後你打開那個文件試一試。保證,你會很爽的,放心只是惡搞。