2012年9月12日

编程练习9

摘要: 1 //删除字符串中字符个数最少的字符 2 #include <iostream> 3 using namespace std; 4 #define N 100 5 6 void remove(char* str,char ch) 7 { 8 int i=0,j,len=strlen(str); 9 int k=len;10 while(i<k)11 {12 if(str[i]==ch)13 {14 for(j=i;j<k-1;++j)15 {16 ... 阅读全文

posted @ 2012-09-12 19:46 lyncre 阅读(156) 评论(0) 推荐(0)

编程练习8

摘要: 回文判断 1 //判断是否为回文 2 #include <iostream> 3 using namespace std; 4 5 void Fun(int num) 6 { 7 int res=0,s=num; 8 do 9 {10 res=res*10+num%10;11 num=num/10;12 }while(num);13 if(res==s) cout<<"Right!";14 else cout<<"Wrong!";15 16 }17 int main()18 {19 int num;20 wh... 阅读全文

posted @ 2012-09-12 10:22 lyncre 阅读(139) 评论(0) 推荐(0)

编程练习7

摘要: 字符的下一个字符//将字符串中的所有字母都替换成该字母的下一个字母#include <iostream>using namespace std;void invert(char* str){ int i; int len=strlen(str); for(i=0;i<len;++i) { if(isalpha(str[i])&&(str[i]!='z')&&(str[i]!='Z')) str[i]=str[i]+1; else if(str[i]=='z') str[i]='a' 阅读全文

posted @ 2012-09-12 10:07 lyncre 阅读(126) 评论(0) 推荐(0)

编程练习6

摘要: 循环数组 1 //数组中的数按步长向右移动,补充到数组头部,简称循环数组 2 #include <iostream> 3 using namespace std; 4 5 void print(int* dig,int n) 6 { 7 for(int i=0;i<n;++i) 8 cout<<dig[i]<<" "; 9 cout<<endl;10 }11 void move(int* dig,int n,int step)12 {13 if (step>=n) return;14 int* tmp=(int*) 阅读全文

posted @ 2012-09-12 10:06 lyncre 阅读(121) 评论(0) 推荐(0)

编程练习5

摘要: 单链表的逆转和排序练习排序还有些问题 1 //链表逆置 指针的指针 2 #include <iostream> 3 using namespace std; 4 5 typedef struct node 6 { 7 int data; 8 node* next; 9 }node; 10 11 node* create() 12 { 13 node *h=(node*)malloc(sizeof(node)),*p; 14 h->data=0; 15 h->next=NULL; 16 p=h; 17 18 int ... 阅读全文

posted @ 2012-09-12 08:47 lyncre 阅读(144) 评论(0) 推荐(0)

编程练习4

摘要: 1 //查找字符串主串中的子串的个数 2 #include <iostream> 3 using namespace std; 4 5 int Findstr(char* str1,char* str2) 6 { 7 int count=0; 8 int len1=strlen(str1); 9 int len2=strlen(str2);10 char *str;11 char tmp[20]={0};12 13 for(int i=0;i<len1-len2+1;++i)14 { 15 strncpy(tmp... 阅读全文

posted @ 2012-09-12 08:46 lyncre 阅读(122) 评论(0) 推荐(0)

导航