- 注册时间
- 2006-2-8
- 最后登录
- 1970-1-1
|
- long xx;
- char str[60],sstr[19];
- long ismid(long nowp,long end){
- long i;
- for(i=nowp;*i>=160&&i>=end;i--);
- return(!((nowp-i)%2));
- }
- //整数输入,参数:(Locate的y,Locate的x)
- long numi(char y,char x){
- long ans,max;
- char k,i;
- char c[11],show[30];
- k=0;ans=0;max=100000000;strcpy(c,"0bnmghjtyu");
- while(k!=13&&k!=27){
- memset(show,0,30);
- Locate(y,x);
- if(ans>max)ans=max;
- printf("%d ",ans);
- k=getchar();
- for(i=0;i<10;i++){if(k==c[i])ans=ans*10+i;}
- if(k==29||k==23)ans=ans/10;
- else if(k==27)ans=-1;
- }//while
- return(ans);
- }
- void stri(char y,char x,int o,int maxl){
- char ch[3],show[21];
- int word,n,l,sx;
- memset(str,0,maxl+1);memset(ch,0,3);strcpy(str,o);n=0;sx=0;
- while(ch[0]!=13){
- memset(show,0,21);
- if(n<sx)sx=n;
- if(n>sx+20)sx=n-20;
- memcpy(show,str+sx,20);
- l=strlen(str);
- if(show[0]>=160&&ismid(str+sx,str))show[0]='_';
- if(show[19]>=160&&!ismid(show+19,show))show[19]='_';
- Locate(4,0);printf(" ");
- Locate(y,0);printf("%s ",show);Box(8*(n-sx),16*y,8*(n-sx)+1,16*y+16,1,2);
- if(ch[0]==22||ch[0]==23){Delay(80);ReleaseKey(128);}
- word=GetWord(3);
- ch[0]=word;
- if(isprint(ch[0])&&l<maxl){memmove(str+n+1,str+n,l-n);str[n]=ch[0];n++;}
- else if(ch[0]>=160&&l<maxl-1){ch[1]=word>>8;memmove(str+n+2,str+n,l-n);memcpy(str+n,ch,2);n=n+2;}
- else if(ch[0]==27){strcpy(str,"");return;}
- else if(ch[0]==29&&n>0){
- if(str[n-1]>=160){memmove(str+n-2,str+n,l-n);memset(str+l-2,0,2);n=n-2;}
- else {memmove(str+n-1,str+n,l-n);str[l-1]=0;n--;}}
- else if(ch[0]==23){if(n==0)n=l;else if(str[n-1]>=160)n=n-2;else n--;
- }//if完
- else if(ch[0]==22){if(n>=l)n=0;else if(str[n]>=160)n=n+2;else n++;
- }//if完
- else if(ch[0]==30){memset(str,0,maxl+1);Locate(y,0);printf(" ");n=0;}
- else if(ch[0]==28)n=0;
- else if(ch[0]==31)n=strlen(str);
- }//while完
- }
- void main()
- {
- SetScreen(0);
- xx=numi(3,1);
- stri(0,0,"默认",10);
- printf("\n%s\n%d",str,xx);
- getchar();
- }
复制代码 从你的EWW中提取出的对我有用的函数,我只想要字符输入和数字输入,请指教stri函数和numi函数中还有没有无关的语句.
找来找去还是这里面的输入最好用,先谢过 |
|