當前位置:編程學習大全網 - 編程語言 - c語言程序設計 密碼設置程序怎麽編寫?

c語言程序設計 密碼設置程序怎麽編寫?

#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=0;i<40;i++)

{

sound(fr[i]);

delay(tim[i]*100000000);

nosound();

}

system("pause");

return 0;

}

  • 上一篇:硬件工程師課程
  • 下一篇:求西門子數控機床指令
  • copyright 2024編程學習大全網