字符串最后一个单词的长度-简单题
2015-08-28 00:00
183 查看
摘要: 输入:一行字符串,长度小于128
输出:整数N,最后一个单词的长度
得分:90
输出:整数N,最后一个单词的长度
得分:90
#include<iostream> using namespace std; int findLastNumLength(char *s,int le) { if(s==NULL||le<=0) return 0; int l=0; char *endl=s; while(*endl) endl++; endl--; while(*endl==' ') endl--; while(le) { if(*endl!=' ') { l++; endl--; } le--; } return l; } int main() { char s[100]; cin.getline(s,100); cout<<findLastNumLength(s,strlen(s)); system("pause"); return 0; }
相关文章推荐
- 输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数-简单题
- Java中内存泄露及垃圾回收机制
- Unity优化大全(三)之CPU-Physics
- Jsp内置对象及EL表达式的使用
- JSP+EL表达式
- 开发监控云组态软件的组成
- 工控领域组态软件开发感触
- RandomAccessFile类
- 动态关闭DIV窗口
- Java程序员新手老手都离不开8大开发工具!
- IT行业发展前景分析
- Masonry
- 在线CRM应变通实施
- 移动前端页面开发:实现页面元素拖动
- freetype 编程入门
- 有关MySQL的数据库规范与日常经验
- sqlplus无法退格 (backspace)
- android Dialog 宽是否占满
- 江苏盐城启动“智慧教育”建设 促进教育现代化发展
- VIEWGOOD(远古)在线访谈在政府行业中的应用