数学建模社区-数学中国

标题: 一个密码输入小程序!有趣!进来看看! [打印本页]

作者: solucky    时间: 2004-6-4 11:33
标题: 一个密码输入小程序!有趣!进来看看!
<>#include "process.h"
) O$ h2 F4 K; \; H1 U! b5 p7 n+ [3 E#include "stdio.h" 6 a1 g2 m, o  T6 n- J( M& P
int main(void) 7 @6 H2 S1 r$ w- i9 h
{
) `. I& ?- P6 K3 O0 a7 h8 Z1 _, ~int i=0,count=0;
% G' u8 I! j' _% `4 B$ ]1 n& a5 fchar c,aa[20],bb[10]="abc"; / q$ L/ p9 d" a" y
clrscr(); . [4 j  Q' }- ~" P! [7 Z
textbackground(1); " F7 d% j5 T( N1 W7 W* B( }
textcolor(4);
4 f$ M# j7 E  |' YLoop: 3 w2 g# s) Y0 v6 ~! U2 I3 C+ F" Q
gotoxy(25,12);   g9 ^" A- d& {2 P
cprintf("Input your password:"); /*当然在这里输入要输入与bb[10]同样的值  */
0 v; y! Y  K& U6 {+ lwhile((c=getch())!=13) ' o: R" {: Y) g0 d8 j4 {1 M2 H8 ^9 m; W
{
3 e. y5 o% q+ v& z$ maa[i++]=c; , e8 |, v3 v+ m
gotoxy(45+i,12); 2 L9 R# k) U4 C. v- J
cprintf("*"); ' Z, Z7 k# M) x1 {
if(i&gt;20)
7 Y: Q! `) M: O" |7 ebreak; 0 }" H( R6 O# [& M$ _( _
}
& S  O% j2 v. Waa=0; # n* r/ y& N2 U5 d# \3 Q
if(strcmp(aa,bb)==0)
( K% ], w4 V5 m  Q{
  a1 V( i) \7 [3 k! Wgotoxy(25,13); * g3 i. _. [5 R6 l' b: m
cprintf("Your password input right!!!");
1 O$ Z1 B3 h0 `' |0 ~: E0 ggotoxy(25,14);0 ~0 r8 L, t6 d( Z9 i0 j
printf("the window will close,thank you");
( A1 z, f' p, p) A% ]delay(10000000);
% H; j  c, B% m0 i4 pgetch(); /*正确输入后,将退出其不意*/7 |: M+ q4 I6 ^+ W
exit(0);
8 K( k& l6 n  ?% {close();
( R. w. P' D( }- B} % F: w; l4 F+ {3 E1 I# U3 j8 ^3 H
else
3 l  k& S% g$ q; E6 C2 a{ i=0;
5 h) ^3 K. |. S4 o2 C. O# \count++;
) G4 D: p  B9 t) {* x0 \gotoxy(25,13); $ ]& {7 u, k+ M8 F
cprintf("Your password input error!!!");
- W8 I$ t0 t1 X! Q3 lgetch();
& c5 i& M0 v  K$ |! q5 y2 F) E{ 0 L  p/ V$ H  C
gotoxy(25,14);
) l$ w, t8 K0 T7 {: Wif(count&gt;3)
) G" W7 H* w# p  f{ / r3 W+ p1 w8 c- I& p, ~3 z
cprintf("You put the wrong number too many times");</P>
& O& v% I6 @/ G  K<>gotoxy(25,15);
7 _7 u# [3 z& R! _$ H  V5 m* q# e" Hcprintf("so the computer must SHOUT DOWN!"); - q4 h) c7 L* l
getch();
( h2 {# B+ v; g( I9 _" v1 eexit(0);
& w+ e1 w9 n& b0 S* Zclose();
! ~6 Z/ \, ~$ o- m4 D9 h}
6 C) P& c4 }6 n7 a" cdelay(10000000000); ' b- e6 v) v6 u; N9 t
clrscr();1 s% q8 Q4 E8 Y7 V( h
goto Loop; # k/ s$ \7 s; W
} 1 U" N" |" _6 V; x4 y
}
- ?1 G' y6 G4 }7 ?/ a+ N. Igetch() ;
) E! R8 F- N* V% R! o3 e}</P>
: q- x0 l5 M- `' C1 x<>              </P>
. x0 J2 g  o9 R. H, x! J. [6 x<>        来源---网上</P>
8 p% X2 t# I: K1 E1 o<>                                          </P>
作者: pride    时间: 2004-6-6 12:34
<>不错不错,只是密码输入后,不能用“Backspace”修改。。</P><>我在里面填了几句,实现修改的功能。</P><> while((c=getch())!=13)
* j+ Q; ~; K8 V& v" p* X2 V0 {* ~3 n  {$ K1 k- q* C0 c% t
   if(c==8){i--;gotoxy(46+i,12);cprintf(" ");gotoxy(46+i,12);}
$ A. P: z# q  s4 S" Z   else{
% C1 t  S. x! J( W  K( i   aa[i++]=c;
4 o; G# V4 s+ @! A8 k   gotoxy(45+i,12);
! e8 v/ u( v# P0 m/ C   cprintf("*");( T; n; {! ]8 ^" h- o
   if(i&gt;20) break;}
& E1 w7 n" Q) g  }</P>
作者: solucky    时间: 2004-6-6 17:04
<>哈哈!</P><>没想到!</P><>谢谢!</P><>再补充</P>
作者: song_luyouqi    时间: 2004-9-15 08:34
标题: 呵呵
小生尝试了一下,果然不错,顶!
作者: david_520042    时间: 2004-9-20 17:42
<>我试过怎么不行???/.cpp2 N* L% l6 }+ |* B! k- C
C:\Documents and Settings\Administrator\1.cpp(7) : error C2065: 'clrscr' : undeclared identifier+ ~/ P) Q& u8 C, b1 u
C:\Documents and Settings\Administrator\1.cpp(8) : error C2065: 'textbackground' : undeclared identifier
# P* F. [$ [% h/ OC:\Documents and Settings\Administrator\1.cpp(9) : error C2065: 'textcolor' : undeclared identifier
+ o+ K0 V* e4 H4 @0 H: V2 OC:\Documents and Settings\Administrator\1.cpp(11) : error C2065: 'gotoxy' : undeclared identifier9 t# n  W, \: s0 v8 c
C:\Documents and Settings\Administrator\1.cpp(12) : error C2065: 'cprintf' : undeclared identifier
. o' N* {. @7 S: I: XC:\Documents and Settings\Administrator\1.cpp(13) : error C2065: 'getch' : undeclared identifier; |% v8 X2 O7 f8 m) B% S/ H  R
C:\Documents and Settings\Administrator\1.cpp(18) : error C2065: 'gt' : undeclared identifier
) Z- H2 {+ x9 \! G4 B6 UC:\Documents and Settings\Administrator\1.cpp(18) : error C2143: syntax error : missing ')' before ';'
" F; M) V& n5 Z$ e# L) Z1 q3 [C:\Documents and Settings\Administrator\1.cpp(18) : warning C4390: ';' : empty controlled statement found; is this the intent?
; k' n4 l4 }- \C:\Documents and Settings\Administrator\1.cpp(18) : error C2059: syntax error : ')'
& G0 g; Y  r! R9 PC:\Documents and Settings\Administrator\1.cpp(19) : error C2143: syntax error : missing ';' before 'break'% A7 s) v1 \2 |' M
C:\Documents and Settings\Administrator\1.cpp(22) : error C2065: 'strcmp' : undeclared identifier
$ [0 _8 n, K4 h9 YC:\Documents and Settings\Administrator\1.cpp(28) : error C2065: 'delay' : undeclared identifier
; h' y$ X3 H3 w: @* _$ V; ~) EC:\Documents and Settings\Administrator\1.cpp(31) : error C2065: 'close' : undeclared identifier& V6 z! F2 e1 ]+ v( p1 ?
C:\Documents and Settings\Administrator\1.cpp(41) : error C2143: syntax error : missing ')' before ';'3 b/ r' |! M) S# H$ ]1 ?% f- {
C:\Documents and Settings\Administrator\1.cpp(41) : warning C4390: ';' : empty controlled statement found; is this the intent?  j# W% }& H8 [% ~. h% @2 g0 }
C:\Documents and Settings\Administrator\1.cpp(41) : error C2059: syntax error : ')'0 |; F! k- p. `) E9 ^0 q7 @9 G
C:\Documents and Settings\Administrator\1.cpp(42) : error C2143: syntax error : missing ';' before '{'
" g' d* d  \, |C:\Documents and Settings\Administrator\1.cpp(43) : error C2143: syntax error : missing ';' before '&lt;': _0 U6 L7 d) g: f  i6 C
C:\Documents and Settings\Administrator\1.cpp(56) : warning C4508: 'main' : function should return a value; 'void' return type assumed# ]  l: j4 F% H! A3 X/ @
C:\Documents and Settings\Administrator\1.cpp(56) : error C2143: syntax error : missing ';' before '&lt;'
; _) x3 ~* o, Q4 \C:\Documents and Settings\Administrator\1.cpp(58) : error C2018: unknown character '0xc0'
# L0 @5 J0 _3 ~2 ^# t4 m( e7 SC:\Documents and Settings\Administrator\1.cpp(58) : error C2018: unknown character '0xb4', z; ~& \# `5 i; t6 @7 o
C:\Documents and Settings\Administrator\1.cpp(58) : error C2018: unknown character '0xd4'
( {! W* ?5 C$ X0 c' B$ ^+ {$ VC:\Documents and Settings\Administrator\1.cpp(58) : error C2018: unknown character '0xb4': f6 r% N7 m9 f# x' W* j
C:\Documents and Settings\Administrator\1.cpp(58) : error C2018: unknown character '0xcd'8 O6 ?; F) a, f0 T& R, h
C:\Documents and Settings\Administrator\1.cpp(58) : error C2018: unknown character '0xf8'
: y& l2 G3 l0 `7 g2 i/ eC:\Documents and Settings\Administrator\1.cpp(58) : error C2018: unknown character '0xc9'
( n/ z0 u  t" R/ p+ D. B; rC:\Documents and Settings\Administrator\1.cpp(58) : error C2018: unknown character '0xcf'
2 N: U: e- Z" i, f6 j: l* cError executing cl.exe.</P><>1.exe - 26 error(s), 3 warning(s)
  h& e  V# G7 f</P>
作者: ilikenba    时间: 2004-9-20 21:14
<>因为你是直接拷贝放在编译器里面执行的!这里网页上有一些不可见的控制符号!所以提示有非法字符!注意将一些空格重新输入一下就行了!</P>




欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5