本文整理汇总了C++中vc::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ vc::push_back方法的具体用法?C++ vc::push_back怎么用?C++ vc::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vc
的用法示例。
在下文中一共展示了vc::push_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(void)
{
int num;
cin >> num;
while (num--) {
int s;
cin >> s;
for (int k = 0; k < s; k++) {
int temp;
cin >> temp;
trains.push_back(temp);
sorted.push_back(temp);
}
sort(sorted.begin(), sorted.end());
int count = 0;
while (sorted != trains) {
for (int i = 0; i+1 < trains.size(); i++) {
if (trains[i] > trains[i+1]) {
int t= trains[i+1];
trains[i+1] = trains[i];
trains[i] = t;
count++;
}
}
}
cout << "Optimal train swapping takes "<< count << " swap(s)." <<endl;
trains.clear();
sorted.clear();
}
}
示例2: check
char check(void){
while (mount.size()) {
if (mount[mount.size()-1] == lake[lake.size()-1]+1) {
lake.push_back(mount[mount.size()-1]);
mount.pop_back();
}
else if (branch.size()){
if (branch[branch.size()-1] == lake[lake.size()-1]+1) {
lake.push_back(branch[branch.size()-1]);
branch.pop_back();
}
else if (branch[branch.size()-1] < mount[mount.size()-1]){
return 'N';
}
else if (branch[branch.size()-1] > mount[mount.size()-1]){
branch.push_back(mount[mount.size()-1]);
mount.pop_back();
}
}
else {
branch.push_back(mount[mount.size()-1]);
mount.pop_back();
}
}
return 'Y';
}
示例3: main
int main(void)
{
int num;
cin >> num;
board = vcc (num, vc (3, 0));
for (int i = 0; i < num; i++) {
int x, y, z;
cin >> x >> y >> z;
board[i][0] = x;
board[i][1] = y;
board[i][2] = z;
sort(board[i].begin(), board[i].end(), wayToSort);
}
sort(board.begin(), board.end(), newComp);
for (int i = 0; i < board.size(); i++) {
list.push_back(board[i][0] * board[i][1] * board[i][2]);
}
/*for (int i = 0; i < board.size(); i++) {
for (int j = 0; j < board[i].size(); j++) {
cout << board[i][j] << " ";
}cout << list[i] << endl;
}*/
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int x, y, z;
cin >> x >> y >> z;
vc foo = {x,y,z};
sort(foo.begin(), foo.end(), wayToSort);
int pro = process(foo);
if (pro)cout << pro << endl;
else cout << "Item does not fit." << endl;
}
}
示例4: recurse
void recurse(int num, string a, string b){
if (!u) {
return;
}
if (a == b && a != "") {
//cout << a << endl;
u=false;
cout << order.size() << endl;
for (int i = 0; i < order.size(); i++) {
cout << order[i] << endl;
}
return;
}
if (num >= m) {
return;
}
for (int i = 0; i < a1.size(); i++) {
string p = a + a1[i];
string q = b + b2[i];
int least = min(p.length(), q.length());
if (p.substr(0, least) == q.substr(0, least)) {
order.push_back(i+1);
recurse(num+1, p, q);
order.pop_back();
}
}
}
示例5: main
int main(void)
{
int cows, stalls;
cin >> cows >> stalls;
vector<bool> grid (stalls+1, false);
umb.push_back(0);
for (int i = 0; i < cows; i++) {
int temp;
cin >> temp;
list.push_back(temp);
}
sort(list.begin(), list.end());
for (int i = 0; i < stalls; i++) {
int temp;
cin >> temp;
umb.push_back(temp);
}
}
示例6: main
int main(void)
{
int test;
cin >> test;
while (test--) {
int num;
cin >> num;
for (int i = 0; i < num; i++) {
int temp;
cin >> temp;
mount.push_back(temp);
}
lake.push_back(0);
cout << check() << endl;
lake.clear();
mount.clear();
branch.clear();
}
}
示例7: main
int main(void)
{
int num;
cin >> num;
for (int i = 0; i < num; i++) {
int temp;
cin >> temp;
board.push_back(temp);
}
sort(board.begin(), board.end());
cout << binary(0, (int) board.size()-1, 17);
}
示例8: main
int main(void)
{
input;
int num;
cin >> num;
for (int i = 0; i < num; i++) {
int temp;
cin >> temp;
list.push_back(temp);
}
}
示例9: best
void best(int index, string a, string b, vc s, vector<bool> limits){
cout << "index: " << index << " a: " << a << " b: " << b<< " ";
for (int w = 0; w < s.size(); w++) {
cout << s[w];
}
cout << endl;
if (s.size() < lim) {
if (a == b) {
cout << "*************************************" <<endl;
bool p = true;
for (int j = 0; j < num; j++) {
if (limits[j] == false) {
p = false;
break;
}
}
if (p == true) {
cout << s.size() << endl;
for (int q = 0; q < s.size(); q++) {
cout << s[q] << endl;
}
return;
}
}
int jkl = 0;
for (int i = 0; i < min(a.length(), b.length()); i++) {
if (a[i] != b[i]) {
jkl++;
}
}
if (jkl == 0) {
for (int i = 0; i < num; i++) {
if (b == "abaaaaaa") {
cout << "yyyyyyyyyyyyyy" <<endl;
}
//cout << i <<endl;
s.push_back(i);
limits[i]= true;
a+=str[0][i];
b+=str[1][i];
if (a == "abaaaaaab" || b == "abaaaaaab")
cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%";
best(i, a, b, s, limits);
limits[i] = false;
s.pop_back();
}
}}
}
示例10: main
int main(void)
{
list.push_back(4);
list.push_back(2);
list.push_back(9);
list.push_back(1);
list.push_back(3);
list.push_back(4);
list.push_back(7);
sort(list.begin(), list.end(), myfunc);
for(int i = 0; i <list.size(); i++){
cout << list[i] << endl;
}
int r, c;
cin >> r >> c;
for (int i = 0; i < num; i++) {
int temp;
cin >> temp;
list.push_back(temp);
}
}
示例11: main
int main(void)
{
int num;
cin >> num;
for (int i = 0; i < num; i++) {
int temp;
cin >> temp;
if (temp == 0) {
list.pop_back();
}
else list.push_back(temp);
}
int sum = 0;
for (int i = 0; i < list.size(); i++) {
sum += list[i];
}
cout << sum;
}
示例12: main
int main(void)
{
int num;
cin >> num;
for (int i = 0; i < num; i++) {
int temp;
cin >> temp;
list.push_back(temp);
}
cout << "enter: ";
int x, y;
cin >> x >> y;
tree = vector<int> (4*list.size(), 0);
build(1,0,list[list.size()-1]);
for (int i = 0; i < tree.size(); i++) {
cout << tree[i] << endl;
}
}
示例13: main
int main(void)
{
freopen("censor.in", "r", stdin);
freopen("censor.out", "w", stdout);
cin >> str >> sub;
for (int i = 0; i < str.length(); i++) {
if (str[i] == sub[0]) {
list.push_back(i);
}
}
while (1) {
bool p = false;
for (int i = 0; list[i] + sub.length() <= str.length() && i < list.size(); i++) {
if (str.substr(list[i], sub.length()) == sub){
p = true;
str.erase(list[i], sub.length());
i--;
}
}
if (!p) {
break;
}
}
/*for (int i = 0; i + sub.length() <= str.length(); i++) {
if (str[i] == sub[0]) {
if (str.substr(i, sub.length()) == sub){
str.erase(i, sub.length());
if (list.size() > 0) {
i = -list.top() -1;
list.pop();
continue;
}
}
else list.push(-i);
}
}*/
cout << str;
}
示例14: main
int main(void)
{
int num;
cin >> num;
for (int i = 0; i < num; i++) {
int temp;
cin >> temp;
board.push_back(temp);
}
sort(board.end(), board.begin());
while (1) {
int cur = board[0]+1;
for (int i = 0; i < board.size(); i++) {
if(board[i] < cur){
cur = board[i];
board[i] = -5;
}
else if (<#condition#>)
}
}
}
示例15: main
int main(void)
{
list.push_back(2);
list.push_back(3);
list.push_back(5);
list.push_back(7);
list.push_back(11);
list.push_back(13);
list.push_back(17);
list.push_back(19);
list.push_back(23);
list.push_back(29);
list.push_back(31);
list.push_back(37);
list.push_back(41);
list.push_back(43);
list.push_back(47);
list.push_back(53);
list.push_back(59);
list.push_back(61);
list.push_back(67);
list.push_back(71);
list.push_back(73);
list.push_back(79);
list.push_back(83);
list.push_back(89);
list.push_back(97);
list.push_back(101);
list.push_back(103);
list.push_back(107);
list.push_back(109);
list.push_back(113);
list.push_back(127);
list.push_back(131);
list.push_back(137);
list.push_back(139);
list.push_back(149);
list.push_back(151);
list.push_back(157);
list.push_back(163);
list.push_back(167);
list.push_back(173);
list.push_back(179);
list.push_back(181);
list.push_back(191);
list.push_back(193);
list.push_back(197);
list.push_back(199);
list.push_back(211);
list.push_back(223);
list.push_back(227);
list.push_back(229);
list.push_back(233);
list.push_back(239);
list.push_back(241);
list.push_back(251);
list.push_back(257);
list.push_back(263);
list.push_back(269);
list.push_back(271);
list.push_back(277);
list.push_back(281);
list.push_back(283);
list.push_back(293);
list.push_back(307);
list.push_back(311);
list.push_back(313);
list.push_back(317);
list.push_back(331);
list.push_back(337);
list.push_back(347);
list.push_back(349);
list.push_back(353);
list.push_back(359);
list.push_back(367);
list.push_back(373);
list.push_back(379);
list.push_back(383);
list.push_back(389);
list.push_back(397);
list.push_back(401);
list.push_back(409);
list.push_back(419);
list.push_back(421);
list.push_back(431);
list.push_back(433);
list.push_back(439);
list.push_back(443);
list.push_back(449);
list.push_back(457);
list.push_back(461);
list.push_back(463);
list.push_back(467);
list.push_back(479);
list.push_back(487);
list.push_back(491);
list.push_back(499);
list.push_back(503);
list.push_back(509);
list.push_back(521);
//.........这里部分代码省略.........