c语言程序设计 密码设置程序怎么编写???

Python021

c语言程序设计 密码设置程序怎么编写???,第1张

#include <stdio.h>

#include <string.h>

#include <conio.h>

int main(int argc,char *argv[])

{

const char user[]="wangpin"/*用户名自己可改动*/

const char password[]="wangpin@126"/*密码自己可改动*/

if(argc == 1)

{

printf("Input error! Usage:filename username password\n")

getch()

exit(1)

}

else if(argc == 3)

{

if (strcmp(argv[1],user) != 0 || strcmp(argv[2],password) != 0)

{

printf("Input error: Invalid username or password\n")

getch()

exit(1)

}

}

printf("Authentication Pass..\n")

sound(500)/*最简单的音乐声*/

delay(50000)

nosound()

getch()

return 0

}

先运行这个程序得到一个exe类型的可执行文件,然后可以复制到c盘根目录下,用桌面左下的图标进入:开始-程序-附件-命令提示符

然后键入 cd \

到c盘根目录下输入

exe文件名 wangpin wangpin@126

就是运行这个程序

------------------------------------------------------------------

------------------------------------------------------------------

下面是一个简单的音乐程序,你可以把它加到上面代替sound()到nosound()那一部分发出<<东方红>>音乐歌曲(小心!声音可能很大)

#include <stdio.h>

#include <stdlib.h>

#include <dos.h>

int main(void)

{

int i,j

int fr[]={392,392,440,294,262,262,220,294,392,392,

440,532,440,392,262,262,220,294,392,294,

262,247,220,196,392,294,330,294,262,262,

220,294,330,294,262,294,262,247,220,196}

int tim[]={4,2,2,8,4,2,2,8,4,4,2,2,2,2,4,2,2,8,4,

4,4,2,2,4,4,4,2,2,4,2,2,2,2,2,2,2,2,2,2,12}

for(i=0i<40i++)

{

sound(fr[i])

delay(tim[i]*100000000)

nosound()

}

system("pause")

return 0

}

#include<stdio.h>

void main()

{

char name

int code

bool b=true

while(b)

{

printf("\n请输入用户名:")

scanf("%s",&name)

printf("\n请输入密码:")

scanf("%d",&code)

if(name=='h'&&code==0)

{

printf("欢迎光临\n")

b=false

}

else{

printf("重新登录\n")

}

}

}

希望对你有所帮助,不明白hi我。。

代码如下:

#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("\n")

if (strcmp(password, "972816") == 0)

{

printf("登录成功\n")

break

}

else

{

i++

if (i != 3)

printf("再输入一次")

}

}

if (i == 3)

printf("密码错误三次退出登录界面\n")

system("pause")

return 0

扩展资料:

#include后面有两种方式,<>;和""前者先在标准库中查找,查找不到在path中查找。后者为文件路径,若直接是文件名则在项目根目录下查找。

引用方法:#include <stdio.h>

注意事项:在TC2.0中,允许不引用此头文件而直接调用其中的函数,但这种做法是不标准的。也不建议这样做。以避免出现在其他IDE中无法编译或执行的问题。

参考资料来源:百度百科—include

参考资料来源:百度百科—stdio.h