摘要: 1 #include<stdio.h> 2 #include<conio.h> 3 int fun(int m,int n) 4 { 5 if(m==n)return 1; 6 if(n==1)return m; 7 return fun(m-1,n)+fun(m-1,n-1); 8 } 9 int main()10 {11 printf("%d\n",fun(7,3));12 getch();13 return 0;14 } 阅读全文
posted @ 2013-05-02 11:04 Please Call me 小强 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<conio.h> 3 int result[100]; 4 5 void split(int n, int k, int c) 6 { 7 if (k == 0) return; 8 if (n == k) 9 {10 result[c]=k;11 for (int i = 0; i <=c; i++)12 printf("%d ",result[i]);13 printf("\n"); 14 if (k == 1)... 阅读全文
posted @ 2013-05-02 11:01 Please Call me 小强 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<conio.h> 3 char pStr[20]="abcd"; 4 void swap(char *a,char *b) 5 { 6 char temp = *a; 7 *a = *b; 8 *b = temp; 9 }10 void comp(char *pBegin)11 {12 if(!*pBegin)puts(pStr);13 char *p=pBegin;14 for(;*p;p++)15 {16 swap(p,pBegin);17 ... 阅读全文
posted @ 2013-05-02 10:58 Please Call me 小强 阅读(219) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<string.h> 3 4 char s[50]; 5 int index=0; 6 void reSort(char *pArray, int remainNum, int printLen) 7 { 8 if (remainNum < printLen)return; 9 if (printLen <= 0)10 {11 for(int i=0;i<index;i++)12 putchar(s[i]);13 putchar('\n');14 ... 阅读全文
posted @ 2013-05-02 10:55 Please Call me 小强 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 整数转换为字符串:char *itoa( int value, char *string,int radix);小数转换为字符串:sprintf(串, 格式控制符列, 数据);字符串转小数:double atof(const char *nptr);字符串转整数:int atoi(const char *nptr);测试代码: 1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() 4 { 5 int a=2013420; 6 float b=2.054f; 7 double c=5.24; 8 char s... 阅读全文
posted @ 2013-05-01 01:29 Please Call me 小强 阅读(282) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 int main() 3 { 4 /*float型数据测试*/ 5 printf("13.37499四舍五入后变为%.2f\n",13.37499f); 6 printf("13.37500四舍五入后变为%.2f\n\n",13.37500f); 7 /*double型数据测试*/ 8 printf("13.4四舍五入后变为%.0lf\n",13.4); 9 printf("13.5四舍五入后变为%.0lf\n",13.5);10 getchar();11 r 阅读全文
posted @ 2013-05-01 00:45 Please Call me 小强 阅读(818) 评论(0) 推荐(0) 编辑
摘要: 30年的改革开放,给中国带来了翻天覆地的变化。2011全年中国手机产量约为11.72亿部。手机已经成为百姓的基本日用品! 给手机选个好听又好记的号码可能是许多人的心愿。但号源有限,只能辅以有偿选号的方法了。 这个程序的目的就是:根据给定的手机尾号(4位),按照一定的规则来打分。其规则如下: 1. 如果出现连号,不管升序还是降序,都加5分。例如:5678,4321都满足加分标准。 2. 前三个数字相同,或后三个数字相同,都加3分。例如:4888,6665,7777都满足加分的标准。注意:7777因为满足这条标准两次,所以这条规则给它加了6分。 3. 符合AABB或者ABAB模式的加1分。例如:2 阅读全文
posted @ 2013-05-01 00:18 Please Call me 小强 阅读(371) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 char a[1500000]={0}; 3 int main() 4 { 5 int temp,n=1, i; 6 for(i=2;i<1500000;i++) 7 for(temp=2*i;temp<1500000;temp+=i) 8 a[temp]=1; 9 for(i=2;i<=100002;i++)10 while(a[n+=2]);11 printf("%d\n",n);12 getchar();13 return 0;14 } 阅读全文
posted @ 2013-04-26 19:25 Please Call me 小强 阅读(338) 评论(0) 推荐(0) 编辑
摘要: 1 #include <stdio.h> 2 3 int fun(int m,int n) 4 { 5 if(m%n==0) 6 return n; 7 return fun(n,m%n); 8 } 9 10 int main(void)11 {12 printf("%d\n",fun(18,14));13 getchar();14 return 0;15 } 阅读全文
posted @ 2013-04-26 19:23 Please Call me 小强 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 一场球赛开始前,售票工作正在紧张的进行中。每张球票为50元,现有30个人排队等待购票,其中有20个人手持50元的钞票,另外10个人手持100元的钞票。假设开始售票时售票处没有零钱,求出这30个人排队购票,使售票处不至出现找不开钱的局面的不同排队种数。(约定:拿同样面值钞票的人对换位置后为同一种排队)方法一:#include<iostream>using namespace std;int main(){ char quque[30];//排队队列 int count_0=0,count_1=0;//收银台count_0表示50的个数,count_1表示100的个数 int i... 阅读全文
posted @ 2013-04-20 12:05 Please Call me 小强 阅读(536) 评论(0) 推荐(0) 编辑