# Include <iostream>
# Include <vector>
Using namespace STD;
Int main (){
Int A [] = {1, 2, 4, 5, 6, 7, 8, 9, 10 };
Vector <int> V (A, A + 10 );
Fill (V. Begin (), V. End (), 20 );
For (vector <int >:: iterator iter = V. Begin (); iter! = V. End (); ++ ITER ){
Cout <* ITER <Endl;
}
System ("pause ");
Return 0;
}
# Include <iostream>
# Include <vector>
# Include <string>
Using namespace STD;
Int main (){
Vector <int> V;
V. Resize (10 );
Fill_n (V. Begin (), 10, 0 );
For (vector <int >:: iterator iter = V. Begin (); iter! = V. End (); ++ ITER ){
Cout <* ITER <Endl;
}
System ("pause ");
Return 0;
}
# Include <iostream>
# Include <vector>
Using namespace STD;
Int main (){
Vector <int> V;
Fill_n (back_inserter (V), 10, 10086 );
For (vector <int >:: iterator iter = V. Begin (); iter! = V. End (); ++ ITER ){
Cout <* ITER <Endl;
}
Cout <Endl;
System ("pause ");
Return 0;
}
Have you found the rule? The premise of fill () is that the container has an available range and a size, and fill_n () can use resize () to determine the capacity, you can also use back_inserter ()