Nemo
A_Nemo_A
嵌入式屌丝
全部博文(398)
LCD驱动分析(3)
shell(26)
linux基础(19)
单片机(23)
面试(38)
网络编程(9)
C++ QT(0)
C++ QT(2)
网络编程(1)
系统编程(27)
web(0)
数据库(0)
linux内核(50)
Android(3)
计算机网络(16)
字符驱动(79)
平台(27)
数据结构(15)
C语言(57)
2013年(398)
shuigsls
wq_db
hu17909
yiguihuo
xinxinha
jason_qi
mordorww
kuangdou
小馒头11
分类: C/C++
2013-08-21 16:51:03
原文地址:C语言面试算法题(二) 作者:frankzfz
#include <stdio.h> #include <stdlib.h> #include <string.h> int FindMax_NumStr(char *outputstr,char *inputstr) { char *in = inputstr,*out = outputstr,*temp; char *final; int count = 0; int maxlen = 0; int i; while(*in!='\0') { if(*in > 47 && *in < 58) { for(temp = in;*in> 47 && *in <58;in++) count++; } else in++; if(maxlen < count) { maxlen = count; count = 0; final = temp; } } for(i =0;i<maxlen;i++) { *out = *final; out++; final++; } *out = '\0'; return maxlen; } void main(void) { char input[]="abc123def123456eec123456789dd"; char output[50] = {0}; int maxlen; maxlen = FindMax_NumStr(output,input); printf("the str %s\n",output); printf("the maxlen is %d\n",maxlen); }
#include <stdio.h> #define NUM 1000 int find5(int num) { int ret = 0; while(num%5==0) { num/=5; ret++; } return ret; } int main(void) { int result = 0; int i; for(i=5;i<=NUM;i+=5) result +=find5(i); printf("the total zero number is %d\n",result); return 0; }
char * search(char *cpSource, char ch) { char *cpTemp=NULL, *cpDest=NULL; int iTemp, iCount=0; while(*cpSource) { if(*cpSource == ch) { iTemp = 0; cpTemp = cpSource; while(*cpSource == ch) ++iTemp, ++cpSource; if(iTemp > iCount) iCount = iTemp, cpDest = cpTemp; if(!*cpSource) break; } ++cpSource; } return cpDest; }
上一篇:C语言面试算法题(一)
下一篇:中兴笔试题
登录 注册