数学建模社区-数学中国

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

作者: solucky    时间: 2004-6-4 11:33
标题: 一个密码输入小程序!有趣!进来看看!
<>#include "process.h"
# N" B2 ?3 ^& D#include "stdio.h" 3 w) j- G- r! o9 R
int main(void) 3 B8 b2 Q4 w2 o
{
. Q9 w3 F3 P, z8 ~% e/ zint i=0,count=0;
% n; i, m9 h1 e: J$ _" v/ h4 f0 Rchar c,aa[20],bb[10]="abc";
- U2 q  b* P* o) u( ]" bclrscr(); 0 }, ~$ S3 M: e6 t* p: B3 F* |
textbackground(1); ! j  W$ K3 O7 W( e
textcolor(4); / l% C# w1 d2 ?0 S# {4 o9 e
Loop:
$ ^& v. [( i; K9 ~- B% Lgotoxy(25,12); : ~4 \, N4 p1 U2 s% v! u+ s" l' P
cprintf("Input your password:"); /*当然在这里输入要输入与bb[10]同样的值  */
0 b9 s3 ^1 j  G$ y; L  P2 |while((c=getch())!=13)
" a! m( G8 L# F{
0 ^- Z2 y9 y0 a% K, I6 v2 Zaa[i++]=c; : m' x* a4 I3 l% ]4 L* g. C
gotoxy(45+i,12); 3 _* K/ A! g) n+ Z5 j& T; h7 d
cprintf("*");
' M( T" ?* H' F" c% T" P( [if(i&gt;20)
5 r2 l# Y5 P# @6 a7 u2 [# \break;
- t/ y1 e0 [: L4 o7 l) W}
, t" ?; L: ^3 v. l; [2 z- }aa=0; ' M1 G9 x0 F& W
if(strcmp(aa,bb)==0)
- D/ L+ v2 b7 ~{
) a# W3 I2 n1 W( Q0 P/ ?$ {6 D2 qgotoxy(25,13);
$ k/ E: i& R/ ccprintf("Your password input right!!!");. K! a- g  ~) I7 Z4 R
gotoxy(25,14);1 v0 R8 H3 V3 a9 ?3 i! K$ c, T
printf("the window will close,thank you");
# j- S, {2 Y; w& ?$ J  Cdelay(10000000); $ c1 h0 [* Z+ u. [+ P
getch(); /*正确输入后,将退出其不意*/* L0 u2 Q. o) I
exit(0);
5 m2 v* t! _$ g0 k3 l4 h( {close(); 4 W. |, ^$ p! r: W# C/ K
} 8 t* G; l0 a: Z0 S( N+ r$ ~
else
0 n2 M' y6 ]# H% g. _{ i=0;
3 ?5 d" H! C# z) x# ucount++; / l$ ^" p8 t% }; |' |$ W
gotoxy(25,13);
/ U* s4 I  ~7 d1 u# T0 ocprintf("Your password input error!!!");   [0 a5 k2 \" i* B* I
getch();
# I/ T6 h/ Z8 C: k0 J& @* n{ ! k+ x: s5 C% S' j% l9 Q
gotoxy(25,14); % v0 i% ^9 y( A( A( I3 ^  f& v- y9 C1 w+ @
if(count&gt;3)
! V) F( k7 y& e! i+ ^4 T1 ?$ G" U{
+ a, `- Q/ q% ?" Acprintf("You put the wrong number too many times");</P>
" J, h; [+ a- y5 t  M- P2 j<>gotoxy(25,15);
( Q# @& y5 t0 V( Y/ B# qcprintf("so the computer must SHOUT DOWN!");
& ]( R8 u8 b. G: _getch();
' b6 N; Y" e" a; I1 T2 Pexit(0);. B0 f* y$ s1 K+ A8 X
close();) G" b4 [  L% J' x3 d
} $ v6 U$ Q' ^6 c3 M4 S& I
delay(10000000000); 9 F- J+ U; R" t
clrscr();- ~( ?9 O# v5 j. d5 A/ A6 w$ I
goto Loop; 5 p7 j/ v0 Q' z& j3 ^2 M
}
3 O0 i$ E- {. x+ {( {} # v( ?9 ]0 E4 Q9 ^
getch() ;
. w& U+ s- c0 f3 ]( `}</P>6 f0 _) ~& k4 {  `
<>              </P>- K6 K( a) W0 h) E* r
<>        来源---网上</P>; T( R0 T% A- V$ ~( s. @5 H
<>                                          </P>
作者: pride    时间: 2004-6-6 12:34
<>不错不错,只是密码输入后,不能用“Backspace”修改。。</P><>我在里面填了几句,实现修改的功能。</P><> while((c=getch())!=13)" R0 G1 a7 I' X) q+ K% S7 F$ I) C& ^
  {/ E! C0 T+ v0 P; X+ w) W3 t
   if(c==8){i--;gotoxy(46+i,12);cprintf(" ");gotoxy(46+i,12);}
. u8 p% n9 T% U% z6 g% E   else{) Z9 ]* a2 V1 ]' ?7 u$ u; P
   aa[i++]=c;5 {6 k1 p+ [& |+ z0 M  ]1 S3 _
   gotoxy(45+i,12);: Z( M: H3 T# V& o7 t2 r
   cprintf("*");& X0 g4 q6 N8 m' g
   if(i&gt;20) break;}+ w9 I7 l' b2 j( r. t/ n7 [6 L
  }</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
<>我试过怎么不行???/.cpp
# [: D, s; d9 H& b  l, Q$ GC:\Documents and Settings\Administrator\1.cpp(7) : error C2065: 'clrscr' : undeclared identifier
6 G& n1 `7 V) e2 d* @( Q. u& oC:\Documents and Settings\Administrator\1.cpp(8) : error C2065: 'textbackground' : undeclared identifier  H9 t6 f8 o* `; B
C:\Documents and Settings\Administrator\1.cpp(9) : error C2065: 'textcolor' : undeclared identifier, Z2 U4 X2 ^+ T% B$ `" ]
C:\Documents and Settings\Administrator\1.cpp(11) : error C2065: 'gotoxy' : undeclared identifier% b; M& N6 M% q+ m# ~/ w2 A+ \( X
C:\Documents and Settings\Administrator\1.cpp(12) : error C2065: 'cprintf' : undeclared identifier
4 R5 i6 }& v' w* R/ P4 LC:\Documents and Settings\Administrator\1.cpp(13) : error C2065: 'getch' : undeclared identifier
2 I1 N; t3 S% y7 x, hC:\Documents and Settings\Administrator\1.cpp(18) : error C2065: 'gt' : undeclared identifier' ~8 D! q0 V$ P1 [
C:\Documents and Settings\Administrator\1.cpp(18) : error C2143: syntax error : missing ')' before ';'6 q* o) ^9 m( G9 `
C:\Documents and Settings\Administrator\1.cpp(18) : warning C4390: ';' : empty controlled statement found; is this the intent?+ Y8 `- c/ W  l$ v
C:\Documents and Settings\Administrator\1.cpp(18) : error C2059: syntax error : ')'
/ H: r- A/ d: t: v: KC:\Documents and Settings\Administrator\1.cpp(19) : error C2143: syntax error : missing ';' before 'break'
3 F, I+ _3 k( w0 T: D8 L* ?8 V4 V# mC:\Documents and Settings\Administrator\1.cpp(22) : error C2065: 'strcmp' : undeclared identifier
  b4 S% r8 u4 O9 P! iC:\Documents and Settings\Administrator\1.cpp(28) : error C2065: 'delay' : undeclared identifier
+ p" @8 l. ~1 @- H8 w' C( wC:\Documents and Settings\Administrator\1.cpp(31) : error C2065: 'close' : undeclared identifier
3 }4 n" T! x3 [7 i2 @+ o% z6 QC:\Documents and Settings\Administrator\1.cpp(41) : error C2143: syntax error : missing ')' before ';'" ^0 Z+ ?4 W, a
C:\Documents and Settings\Administrator\1.cpp(41) : warning C4390: ';' : empty controlled statement found; is this the intent?
: Q- d- r# D( fC:\Documents and Settings\Administrator\1.cpp(41) : error C2059: syntax error : ')'
  c5 S: X9 u/ B8 U( ?C:\Documents and Settings\Administrator\1.cpp(42) : error C2143: syntax error : missing ';' before '{'; Y9 m1 F  s* [: }) f6 `
C:\Documents and Settings\Administrator\1.cpp(43) : error C2143: syntax error : missing ';' before '&lt;'
( _# p5 U: O3 J- R" Q' B/ F, a4 UC:\Documents and Settings\Administrator\1.cpp(56) : warning C4508: 'main' : function should return a value; 'void' return type assumed
9 M+ M2 w5 A. P2 _+ T6 i% ?C:\Documents and Settings\Administrator\1.cpp(56) : error C2143: syntax error : missing ';' before '&lt;'! [; e% i( S" C1 [
C:\Documents and Settings\Administrator\1.cpp(58) : error C2018: unknown character '0xc0'1 `' Z( p  M9 ]6 H+ T3 z# w
C:\Documents and Settings\Administrator\1.cpp(58) : error C2018: unknown character '0xb4'6 F8 m* b' P! S' E+ ^- D( b( c
C:\Documents and Settings\Administrator\1.cpp(58) : error C2018: unknown character '0xd4'* u# i. m& `& V) ], \5 \
C:\Documents and Settings\Administrator\1.cpp(58) : error C2018: unknown character '0xb4'3 [* j& i2 `) G7 v0 ^
C:\Documents and Settings\Administrator\1.cpp(58) : error C2018: unknown character '0xcd'
9 z* b2 X, ]+ t2 d* j* vC:\Documents and Settings\Administrator\1.cpp(58) : error C2018: unknown character '0xf8'
) u- C8 q! ~0 S) hC:\Documents and Settings\Administrator\1.cpp(58) : error C2018: unknown character '0xc9'
( [' r2 A7 O/ D3 q; QC:\Documents and Settings\Administrator\1.cpp(58) : error C2018: unknown character '0xcf'6 T4 O' F# r/ h3 n
Error executing cl.exe.</P><>1.exe - 26 error(s), 3 warning(s)
: I4 {' n# d7 R2 I: s( o. K, b' x</P>
作者: ilikenba    时间: 2004-9-20 21:14
<>因为你是直接拷贝放在编译器里面执行的!这里网页上有一些不可见的控制符号!所以提示有非法字符!注意将一些空格重新输入一下就行了!</P>




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