摘要: 转自stven_king的博客这是一个求一个排序的下一个排列的函数,可以遍历全排列,要包含头文件<algorithm>下面是以前的笔记(1) int 类型的next_permutationint main(){int a[3];a[0]=1;a[1]=2;a[2]=3;do {cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;} while (next_permutation(a,a+3)); //参数3指的是要进行排列的长度//如果存在a之后 阅读全文
posted @ 2012-05-09 22:01 狸の舞 阅读(454) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <math.h>struct point_node{ int x, y;}point[1005];int n;bool func ( point_node a, point_node b, point_node c ){ if ( ( ( c.x - a.x ) * ( b.x - a.x ) + ( c.y - a.y ) * ( b.y - a.y ) == 0 ) && ( ( c.x - a.x ) * ( c.x - a.x ) + ( c.y - a.y ) * ( c.y - a.y ) 阅读全文
posted @ 2012-05-09 21:53 狸の舞 阅读(218) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<stdio.h> 2 int main() { 3 char s[99]; 4 int a, b, c, n = 0; 5 while(scanf("%s", &s) == 1) { 6 if(sscanf(s, "%d+%d=%d", &a, &b, &c) == 3 && a+b==c) n++; 7 if(sscanf(s, "%d-%d=%d", &a, &b, &c) == 3 && 阅读全文
posted @ 2012-05-09 16:37 狸の舞 阅读(233) 评论(0) 推荐(0) 编辑