fill是按照单元来赋值的,所以可以填充一个区间的任意值
#include<iostream>#include<stdio.h>#include<string.h>#include<cmath>#include<math.h>#include<algorithm>#include<set>typedef long long ll;using namespace std;#define INF 1e9+7int main(){int a[100];fill(a,a+10,100);for(int i=0;i<10;i++)printf("%d ",a[i]);return 0;}
memset函数一般只用于赋初值为0或者-1
#include<iostream>#include<stdio.h>#include<string.h>#include<cmath>#include<math.h>#include<algorithm>#include<set>typedef long long ll;using namespace std;#define INF 1e9+7int main(){int a[100];memset(a,-1,sizeof(a));for(int i=0;i<10;i++)printf("%d ",a[i]);return 0;}