fill()算法确实好用,虽然不知道,时间复杂度是多少,但是用起来好方便的,,我觉得时间复杂度应该不高吧? 上百度查了一下也查不出来.
还有那个遍历算法,也是很省事的呼呼.,..
而且还可以加函数算法op();确实神奇...
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <time.h>
using namespace std;
int coun;
bool op(int a)
{
printf("%d ",a);
coun++;
if(coun==10)
{
coun=0;
puts("");
}
return 1;
}
int main()
{
int a[1000];
coun=0;
fill(a,a+1000,1);
for_each(a,a+1000,op);
return 1;
}