![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++编程
JoyHao666
这个作者很懒,什么都没留下…
展开
-
C/C++输入读取数据函数总结
C语言1、scanf/getchar函数读取字符scanf/getchar:从输入流缓冲区中读取值,读取时遇到回车(/n)而结束,不舍弃空格、回车字符;#include char ch1, ch2;scanf("%c", &ch1); ch2 = getchar();2、scanf/gets函数读取字符原创 2015-08-14 17:04:27 · 1282 阅读 · 0 评论 -
字符串最后一个单词长度
#includeusing namespace std;#includeint main(){ string str; while(getline(cin,str)) { int len=str.size(); int p=0; int q=0; while(p { if(str[p]==' ')原创 2015-09-13 11:07:00 · 239 阅读 · 0 评论 -
字符串过滤函数
字符串过滤函数:输出的字符串只保留大小写字母原创 2015-09-13 11:52:24 · 504 阅读 · 0 评论 -
C++字符串的使用
1.必须包含#include2.定义和初始化形式:string str;//构造空字符串 string str("Hello, string!\n");string str1(str);3.字符串大小和非空int length=str.size();if(str.empty()){}4.拷贝str1=str;5.连接string s3=s1+s2+"原创 2015-09-13 11:54:44 · 275 阅读 · 0 评论 -
字符串过滤函数-字符串输出后只保留大小写字母
#include#includeusing namespace std;int main(){ string str; getline(cin,str); int len=str.size(); int p=0; int q=0; while(q { if((str[q]>='A'&&str[q]='a'&&str[q原创 2015-09-13 11:50:14 · 2767 阅读 · 0 评论