
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 · 1348 阅读 · 0 评论 -
字符串最后一个单词长度
#include using namespace std; #include int 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 · 269 阅读 · 0 评论 -
字符串过滤函数
字符串过滤函数:输出的字符串只保留大小写字母原创 2015-09-13 11:52:24 · 535 阅读 · 0 评论 -
C++字符串的使用
1.必须包含#include 2.定义和初始化形式: 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 · 297 阅读 · 0 评论 -
字符串过滤函数-字符串输出后只保留大小写字母
#include #include using 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 · 2799 阅读 · 0 评论