搜索
编程论坛
→
开发语言
→
C++论坛
→
『 C++教室 』
→ 帮忙解决一下“输入一行字符,要就输出其相应的密码”谢谢
标题:
帮忙解决一下“输入一行字符,要就输出其相应的密码”谢谢
只看楼主
灵树
等 级:
新手上路
帖 子:2
专家分:0
注 册:2010-4-10
结帖率:
0
楼主
已结贴
√
问题点数:20 回复次数:4
帮忙解决一下“输入一行字符,要就输出其相应的密码”谢谢
帮忙解决一下“输入一行字符,要就输出其相应的密码”谢谢
搜索更多相关主题的帖子:
输出
输入
字符
密码
2010-04-13 23:59
cnfarer
等 级:
版主
威 望:
179
帖 子:3330
专家分:21157
注 册:2010-1-19
第
2
楼
得分:6
#include<iostream>
using namespace std;
void main()
{
char c, str[100];
int i=0;
printf("Input : ");
while((c=getchar())!='\n')
{
str[i++]=c+10;
}
str[i]='\0';
printf("Output: ");
printf("%s\n",str);
}
★★★★★
为人民服务
★★★★★
2010-04-14 09:58
asdjc
来 自:武汉
等 级:
侠之大者
威 望:
7
帖 子:98
专家分:487
注 册:2010-1-22
第
3
楼
得分:6
我觉得应该告诉我们要用的是那种密码吧?
二楼的cnfarer高手写的是进十处理的密码。(好像有点不好的地方,str[i++]=c+10
改为str[i++]=(c+10)%26会不会好点?)
2010-04-17 12:52
yyblackyy
等 级:
侠之大者
帖 子:98
专家分:457
注 册:2010-3-31
第
4
楼
得分:6
#include<stdio.h>
#include<conio.h>
#define Max 100
int main()
{
char str[Max];
char ch,*ps=str;
for(;;)
{
if(kbhit())
{
ch=getch();
if(ch=='\r')
{
*ps='\0';
break;
}
else
{
*ps++=ch;
putchar('*');
}
else //减少系统的CPU的,不知道则么写
{
; //运行还可以,就是这个CPU。。。高了
}
}
}
printf("\n%s\n",str);
ps=0;
return 0;
}
2010-04-20 00:31
yyblackyy
等 级:
侠之大者
帖 子:98
专家分:457
注 册:2010-3-31
第
5
楼
得分:0
#include<stdio.h>
//这个不太占用太多的CPU
#include<conio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char ch,str[512],*p=str;
while(ch=getch())
{ unsigned count=0;
if(ch=='\10')
{
system("cls");
if(strlen(str))
{
*(--p)=0;
count=strlen(str);
for(unsigned i=0;i<count;i++)
putch('*');
}
continue;
}
if(ch=='\n'||ch=='\r')
{
/* *p++='\n'; 去掉注释符和break 的话 Enter键也能使了,用F某某键跳出
*p=0;
putch('*');
continue;
*/
break;
}
*p++=ch;
*p=0;
putch('*');
}
system("cls");
printf("%s\n",str);
return 0;
}
2010-04-20 14:35
5
1/1页
1
参与讨论请移步原网站贴子:
https://bbs.bccn.net/thread-302906-1-1.html
关于我们
|
广告合作
|
编程中国
|
清除Cookies
|
TOP
|
手机版
编程中国
版权所有,并保留所有权利。
Powered by
Discuz
, Processed in 0.047862 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved