摘要: 阅读全文
posted @ 2013-11-19 19:20 博园少主 阅读(166) 评论(0) 推荐(0) 编辑
摘要: #include int partition(int A[], int p, int q) { int x = A[p]; int i = p; int j; for (j=p+1; jint quick_sort(int a[], int low, int high)//一趟排序找出并确定枢轴位置{ int key = 0; a[0]= a[low]; key = a[low]; while (low = key) high--; a[low] = a[high]; while (low int quick_sort... 阅读全文
posted @ 2013-11-19 18:51 博园少主 阅读(118) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std;const int N=50;const int M=50;char a[N][M];bool pathed[N][M];//留下足迹数组short int p[4][2]={-1,0,0,1,1,0,0,-1};//行走方向数组int n,m;//行列变量int dfs(int,int);int main(){ int i,j,sum; while (scanf("%d%d",&n,&m)!=EOF) { sum=0; memset(pathed,0,sizeof(pathed)); ... 阅读全文
posted @ 2013-11-19 18:42 博园少主 阅读(258) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std;const int N=100;const int M=100;typedef struct //定义迷宫结构{ char c; short int p_row,p_col,step;}Maze;Maze a[N][M];bool pathed[N][M]; //留下足迹数组short int p[4][2]={-1,0,0,1,1,0,0,-1};//行走方向数组int n,m;//行列变量int bfs(int,int);typedef struct //定义队列结构{ int row,col... 阅读全文
posted @ 2013-11-19 18:40 博园少主 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 分拆素数和Problem Description把一个偶数拆成两个不同素数的和,有几种拆法呢? Input输入包含一些正的偶数,其值不会超过10000,个数不会超过500,若遇0,则结束。 Output对应每个偶数,输出其拆成不同素数的个数,每个结果占一行。 Sample Input30260 Sample Output32 #include using namespace std;int f(int n){int i;for(i=2;i*i>n,n) { s=0; for(i=2;iusing namespace std;#define N 10000int... 阅读全文
posted @ 2013-11-19 18:27 博园少主 阅读(142) 评论(0) 推荐(0) 编辑
摘要: //开灯问题#include #include using namespace std;const int m=1000+10;int main( ){ int n,k,a[m],i,j,flag=1; cin>>n>>k; memset(a,-1,sizeof(a)); for (j=1;jint main( ){ int k,i,tag ;for(i=2;i<100;i++){ tag=0; for(k=2;k<i;k++) if(i%k==0) tag=1 ; if(tag==0) printf("%d",i);} } 阅读全文
posted @ 2013-11-19 14:02 博园少主 阅读(145) 评论(0) 推荐(0) 编辑
摘要: #include int main() { int i,j,n,s,k; int a[1000]; while(scanf("%d",&n)&&n!=-1) { s=0; k=0; for(j=1;jint main(){ int n,i,j,s,k,a[10000]; scanf("%d",&n); { s=0; k=0; for (j=1;jint main(){ int n,i,j,s; scanf("%d",&n); { s=0; for (j=1;jint main( ){ ... 阅读全文
posted @ 2013-11-19 13:58 博园少主 阅读(281) 评论(0) 推荐(0) 编辑
摘要: p91#include #includeint main ( ){ int m,i,k ;scanf("%d",&m);k=sqrt(m) ;for(i=2 ; ik) printf("%d is a prime number\n",m) ; else printf("%d is not a prime number\n",m) ; return 0;}#includeint isprime(int a);main(){int x; scanf("%d",&x);if(isprime(x))prin 阅读全文
posted @ 2013-11-19 13:35 博园少主 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 1 1306 循环求素数10.1.5.253 2 3 C语言:循环结构9(求素数) 4 时间限制(普通/Java):1000MS/3000MS 5 总提交:901 测试通过:396 6 7 描述 8 9 10 输入二个整数a和b(2 39 int prime(int x) 40 { int i; 41 for(i=2; i 63 int main() 64 { 65 int n,a,b,i; 66 a>=2; 67 a=n) 76 printf("%d ",... 阅读全文
posted @ 2013-11-19 12:37 博园少主 阅读(872) 评论(0) 推荐(0) 编辑