字符串
文章平均质量分 85
如雨星空
推荐系统在读研究生
展开
-
Hdu 2024C语言合法标识符
C语言合法标识符Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 54914 Accepted Submission(s): 21699Problem Description输入一个字符串,判断其是否是C的合法标原创 2016-01-31 00:41:11 · 429 阅读 · 0 评论 -
字符串处理之gets与scanf("%s")的区别
一、快速了解1.scanf( )函数和gets( )函数都可用于输入字符串,但在功能上有区别。若想从键盘上输入字符串"hi hello",则应该使用__gets__函数。2.gets可以接收空格,回车结束,gets(s)是输入一行;而scanf(%s)遇到空格、回车和Tab键都会认为输入结束,所以它不能接收空格。char string[15]; gets(string); /*遇到...原创 2016-02-26 23:40:20 · 22929 阅读 · 4 评论 -
循环中超时的strlen
1.惨痛的教训 strlen所作的仅仅是一个计数器的工作,它从内存的某个位置(可以是字符串开头,中间某个位置,甚至是某个不确定的内存区域)开始扫描,直到碰到第一个字符串结束符'\0'为止,然后返回计数器值(长度不包含'\0')。我们用cin>>s和scanf(%s)输入字符串时,会在接受完字符串后在末尾加个'\0',也就是NULL作为字符串结束符。用strlen函数求解字符原创 2017-10-13 17:19:53 · 1062 阅读 · 1 评论 -
字符串处理之字符串流的创建
#include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define INT_MAX 1 << 30typedef long long ll;int n;int原创 2016-04-15 22:23:27 · 931 阅读 · 0 评论 -
poj3617_简单贪心
Best Cow LineTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 18790 Accepted: 5228DescriptionFJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual原创 2016-08-03 20:04:42 · 370 阅读 · 0 评论 -
scanf("%c")和getchar
1.scanf("%c")scanf等待回车输入后,准确说是'\n'输入后,从缓冲区中读取数据,称为等待回车输入;这也是我们很多次输入数据要按回车键的原因。scanf读取数据时,简单来说分为两种一种是读取字符scanf("%c"),由于tab,空格,和回车都有自己对应的ascaii码,tab为9,空格为32,回车为10,所以输入数据时要谨防这些间隔符被当成字符输入;一种是输原创 2016-08-03 20:58:36 · 4629 阅读 · 2 评论 -
poj2685——Numeral System新进制系统
Numeral SystemTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 2227 Accepted: 1713DescriptionProf. Hachioji has devised a new numeral system of integral原创 2016-04-29 16:20:17 · 639 阅读 · 0 评论 -
Hdu 1328 IBM Minus One 字符串处理的两种方法
IBM Minus OneTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5193 Accepted Submission(s): 2668Problem DescriptionYou may原创 2016-01-30 23:07:57 · 395 阅读 · 0 评论 -
Hdu 2026 首字母大写
首字母变大写Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 45549 Accepted Submission(s): 25284Problem Description输入一个英文句子,将每个单词的第一原创 2016-02-23 11:01:37 · 771 阅读 · 0 评论 -
while函数输入小结
1.知识点1:scanf函数的返回值可以简单理解为为输入变量的个数:Both scanf and wscanf return the number of fields successfully convertedand assigned; the return value does not include fields that were read but not assigned. A原创 2016-03-17 18:10:25 · 1383 阅读 · 0 评论 -
c++中 gets(s)、scanf(%s) 、getline(s)、cin >> s 比较
1.gets和getline读取换行符//gets读取回车:string a;char b[100];int main(){ cin >> a; gets(b); cout << "a:" << a << endl; cout << "b:" << b << endl; return 0;}//getline读取回车string a;string b原创 2017-11-01 23:01:15 · 1673 阅读 · 0 评论