
面试题
火箭丸子
艾比斯星球战神
展开
-
(1451)求一个字符串中连续出现次数最多的子串
#include #include #include #include using namespace std;pair fun(const string& str){ vector substrs;//存放所有子串 int maxcount=1,count=1; string substr; int i,len=str.length(原创 2012-03-20 17:26:51 · 1017 阅读 · 0 评论 -
(1454)将一句话中的单词倒置,标点符号不倒置。
#include #include #include /*句子中单词倒置,标点不倒置*/using namespace std;void reverse(char *str){ cout<<str<<endl; char *a=str; char temp; int i=0,j=0; int begin=0,end=0; //原创 2012-03-20 17:22:30 · 2427 阅读 · 0 评论 -
(1453)重写strstr()函数,返回为主串中字符子串的位置以后的所有字符
#include #include /*重写strstr()函数,返回为主串中字符子串的位置以后的所有字符*/using namespace std;const char* strstr1(const char* string,const char * strCharSet){ for(int i=0;string[i]!='\0';i++) {原创 2012-03-20 17:23:36 · 1625 阅读 · 0 评论 -
(1452)找出字符串中出现的相同的且长度最长的字符串,输出它及其首字母的位置
#include #include #include using namespace std;/*yyabcdabjcabceg输出:abc 3*/int main(int argc, char *argv[]){ string str,tep; cout<<"请输入字符串"<<endl; cin>>str; for(int i=str.length(原创 2012-03-20 17:25:24 · 1642 阅读 · 0 评论 -
(1423)编写函数实现字符串循环右移n位
#include #include #include #define MAXLEN 20/*编写循环函数,使一个字符串循环右移n个字符*/using namespace std;void LoopMove1(char *str,int n){ char *p=str; char temp[MAXLEN]; int len=strlen(str);原创 2012-03-15 22:01:39 · 2924 阅读 · 0 评论 -
(1411)实现字符串与整数的相互转换(不使用itoa和atoi)
#include #include #include using namespace std;char *inttostring(int num,char *str)//整数转成字符串 { int i=0; char temp[10]; while(num!=0) { str[i]=num%10+'0';原创 2012-03-15 16:41:45 · 804 阅读 · 0 评论 -
(1461)转换字符串为字符+字符连续出现的次数
#include #include #include using namespace std;int main(int argc, char *argv[]){ cout<<"input the numbers"<<endl; string str; getline(cin,str); char res[50]; res[0]='\0'; i原创 2012-03-20 17:54:12 · 542 阅读 · 0 评论 -
汉诺塔的递归实现
#include #include using namespace std;int counts=0;//DEVC++中count不能被定义为全局变量 void hanoi(char fromTower,char toTower,char auxTower,int n);int main(int argc, char *argv[]){ int numDisks;原创 2012-05-14 10:20:46 · 2542 阅读 · 0 评论 -
java实现金额数字转换为中文大写
import java.io.*;import java.lang.IllegalArgumentException;public class ConvertNum{ /** * 把金额阿拉伯数字转换为汉字表示,小数点后四舍五入保留两位 * 还有一种方法可以在转换的过程中不考虑连续0的情况,然后对最终的结果进行一次遍历合并连续的零 */ public static原创 2012-12-10 10:00:27 · 6074 阅读 · 0 评论