一道C机试题目
来源:互联网 发布:金融网络销售靠谱吗 编辑:程序博客网 时间:2024/04/30 13:45
题目是这样的
求一个字符串中连续字母的个数
比如I have a book. : 1
I have a dog. : 0
I haavee aa dogg : 4
#include <windows.h>#include <iostream>using namespace std;void GetDupStringCount( const char* pStr, int &iOut ){if( !pStr )return;int iLen = strlen( pStr );if( !iLen )return;char cValue = *pStr;int iNumCount = 0;//重复个数iOut = 0;//设置为0int iIndex = 0;//当前索引while( iLen-- ){if( !( ( cValue >= 'a' && cValue <= 'z' ) || ( cValue >= 'A' && cValue <= 'Z' ) ) ){cValue = *( pStr + ++iIndex );iNumCount = 0;continue;}if( cValue == *( pStr + iIndex ) ){iNumCount++;}else{cValue = *( pStr + iIndex );if( iNumCount > 1 ){iOut++;iNumCount = 0;--iIndex;}}iIndex++;}}int main( int argc, char* argv[] ){char szStr[] = " I haveee a book! ";int iOut = -1;GetDupStringCount( szStr, iOut );cout << iOut << endl;return 0;}
- 一道C机试题目
- 一道c面试题
- 一道C面试题。
- 一道c面试题
- 一道C语言面试题
- 一道C的面试题
- 一道C语言面试题
- 一道C语言面试题
- 华为一道机试题
- 一道zhangying机试题
- 一道机试题
- 一道华为简单面试题(C/C++)
- 一道面试题(c/c++)
- 一道C面试题引发的思考
- 华为一道c语言面试题
- 华为一道c语言面试题
- 一道C语言面试题的解答
- 一道c的面试题,大数相乘
- 2013 多校第六场 hdu 4662 MU Puzzle
- 使用autoit解决webdriver文件上传问题
- USACO 2.2.3 Runaround Numbers 循环数
- hdu1104Remainder (BFS)
- Struts2 <s:actionerror>标签覆盖
- 一道C机试题目
- 使用ocx(host ocx)
- ios开发第一篇 简单的qq登录窗口
- python优化
- rails 的 Helpers
- android 中写rom文件命名时一点小小的总结
- 【算法导论】C++参考源码之线性时间排序
- 黑马程序员—多线程(上)-线程及其创建方法
- Linux软件的安装、卸载