![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
ACM
记得最初的梦想
一个单纯的程序员
展开
-
全排列问题
//方法一,利用STL中的全排列算法 #include #include using namespace std; int main(){ int a[] = {1,2,3}; do{ cout << a[0] << " " << a[1] << " " << a[2] << endl; } while (next_permutation(a,a+3)); //next_permut原创 2012-05-21 09:38:48 · 558 阅读 · 0 评论 -
scanf和cin的返回值
需要连续从标准输入读取数据时,可以采用下面两种不同的方式判断文件结束: int i; while(scanf("%d",&i) != EOF){do whatever...} while(cin >> i){do whatever...} 首先看scanf,当成功读取时返回读取的项的数目,如:scanf("%d %d",&i,&j)返回2,scanf("%d %f %s",&转载 2012-05-21 09:51:10 · 855 阅读 · 0 评论 -
C++ STL Algorithm
1. 复制一个范围的元素 copy() Copies the elements in the range [first,last) into a range beginning at result. 应用:接收标准输入保存到容器;输出容器内的元素。 copy(istream_iterator(cin), istream_iterator(), back_insert_iterat转载 2012-05-21 09:53:23 · 823 阅读 · 0 评论 -
STL prev_permutation&next_permutation
在标准库算法中,next_permutation应用在数列操作上比较广泛.这个函数可以计算一组数据的全排列.但是怎么用,原理如何,我做了简单的剖析. 首先查看stl中相关信息. 函数原型: template bool next_permutation( BidirectionalIterator _First, BidirectionalIterato转载 2012-05-21 10:01:25 · 690 阅读 · 0 评论 -
大数阶乘
#include using namespace std; int main(){ int a[40000]; //100的阶乘也不会超过40000位,结果的每一位都放到数组的每一位中 int n,i,j,temp,r=0,len=1; //初始化参数,n:要计算阶乘的数,r为进位,len为中间结果的长度 while(cin>>n){ len=1,r=0,a[0]=1; /原创 2012-05-20 12:07:55 · 650 阅读 · 0 评论 -
[HDU]1006 Tick and Tick
这是HDU,Obline Judge上的一道题,先来没事,研究的做做,原创 2014-04-16 11:50:35 · 1033 阅读 · 0 评论