• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
乐碎碎
程序媛想的事儿
博客园    首页    新随笔    联系   管理    订阅  订阅
上一页 1 ··· 3 4 5 6 7
2012年10月4日
将一个输入的数字颠倒(例如输入12345->54321)
摘要: 用算法实现将一个输入的数字颠倒(输入12345->54321),要求不调用任何系统函数,也不能将输入的数字转换为字符串作为中间过渡 1 //用算法实现将一个输入的数字颠倒(输入12345->54321),要求不调用任何系统函数,也不能将输入的数字转换为字符串作为中间过渡 2 #include "stdafx.h" 3 4 long reverse(long num) 5 { 6 long x=0; 7 while(num) 8 { 9 x=x*10;10 x=x+num%10;11 ... 阅读全文
posted @ 2012-10-04 18:37 xingle0917 阅读(1693) 评论(1) 推荐(1)
删除一个字符串中的子串
摘要: 1 // 删除一个字符串中的子串 2 3 #include "stdafx.h" 4 #include 5 6 int delete_substr(char *str1,char *str2) 7 { 8 int pos=0,k=0,staic=0,n; 9 int str1_len=strlen(str1);10 int str2_len=strlen(str2);11 for(int i=0;i<str1_len;i++)12 {13 for(int j=0;j<str2_len;j++)14 {15 ... 阅读全文
posted @ 2012-10-04 18:35 xingle0917 阅读(438) 评论(0) 推荐(0)
字符串查找子串
摘要: 不调用任何系统函数,实现一个字符串查找子串的函数,如果包含字串,则返回该字符串的位置值,如果不包含,则返回-1 1 //不调用任何系统函数,实现一个字符串查找子串的函数,如果包含字串,则返回该字符串的位置值,如果不包含,则返回-1 2 #include "stdafx.h" 3 #include 4 5 //方法1 6 int search_max_substr1(const char *str1,const char *str2)//在str1中查找子串str2 7 { 8 int pos=0,k=0,staic=0; 9 int str1_len=strlen(str1 阅读全文
posted @ 2012-10-04 18:33 xingle0917 阅读(613) 评论(0) 推荐(0)
输出100以内的质数
摘要: 1 #include "stdafx.h" 2 #include 3 # define MAX 100 4 5 void main() //输出100以为的质数 6 { 7 int i,j; 8 for(i=1;i<=MAX;i++) 9 {10 for(j=2;j<=i;j++)11 {12 if(i%j==0)13 break;14 }15 if(i==j)16 printf("%d\t",i);17 }18... 阅读全文
posted @ 2012-10-04 18:25 xingle0917 阅读(222) 评论(0) 推荐(0)
判断一个数是不是回文数
摘要: 1 #include "stdafx.h" 2 #include 3 4 bool Is_palindromic(int num) //判断一个数是不是回文数 5 { 6 int pal=0; 7 int number=num; 8 while(num) 9 {10 pal*=10;11 pal+=num%10;12 num/=10;13 }14 return pal==number;15 }16 17 void main()18 {19 int n,m;20 printf("... 阅读全文
posted @ 2012-10-04 18:19 xingle0917 阅读(466) 评论(1) 推荐(0)
最大公共子串
摘要: 1 #include "stdafx.h" 2 #include 3 #include 4 #define MAX 100 5 6 //在字符串str1和str2中查找最大的公共子串maxsubstr 7 void findmaxsubstr(const char *str1,const char *str2,char *maxsubstr) 8 { 9 int maxlen=0,maxpos=-1;10 int k;11 for(int i=0;imaxlen)22 {23 ... 阅读全文
posted @ 2012-10-04 18:16 xingle0917 阅读(240) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3