</pre><pre class="cpp" name="code">/*
*copyright (c) 2014,烟台大学计算机学院
*All rights reserved
*文件名称:qwe.cpp
*作者:孙春红
*完成日期:2014年10月30日
*版本号:v1.o
*问题描述:输出M$pszi$y的意义
*/
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
char ch;
while((ch=getchar())!='\n')
{
putchar(ch-4);
}
return 0;
}
运行结果:
扩展:因为两个人的“加密”手段泄露,决定纸条由人传,加密数字(1-9)用俩人约好的手势传。所以在解密前,需要将加密数次提前输入。
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int n=4;
char ch;
cout <<"请输入密码:";
cin >>n;
while((ch=getchar())!='\n')
{
putchar(ch-4);
}
return 0;
}
运行结果:
知识点总结:
学会运用字符串编写程序
学习心得:
好难啊!!对于字符串来说,还稍微有点陌生,总是感觉很生涩,还需要继续努力啊!!