本文整理汇总了C++中vc::size方法的典型用法代码示例。如果您正苦于以下问题:C++ vc::size方法的具体用法?C++ vc::size怎么用?C++ vc::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vc
的用法示例。
在下文中一共展示了vc::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
}
}
示例2: getCanonicalMatrix
void getCanonicalMatrix(vvd& a, vd& b, vd& c, const vc& sign, const vc& type)
{
vvd a1;
vd b1;
vd c1 = c;
for (size_t i = 0; i < type.size(); ++i)
{
if (type[i] == '<')
{
a1.push_back(a[i]);
b1.push_back(b[i]);
}
if (type[i] == '>')
{
a1.push_back(a[i]);
for (auto& j : a1.back())
{
j = -j;
}
b1.push_back(-b[i]);
}
if (type[i] == '=')
{
a1.push_back(a[i]);
b1.push_back(b[i]);
a1.push_back(a[i]);
for (auto& j : a1.back())
{
j = -j;
}
b1.push_back(-b[i]);
}
}
for (int i = (int)sign.size() - 1; i >= 0; --i)
{
if (sign[i] == '0')
{
for (auto& v : a1)
{
v.insert(v.begin() + i + 1, -v[i]);
}
c1.insert(c1.begin() + i + 1, -c1[i]);
}
}
a = a1;
b = b1;
c = c1;
}
示例3: 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();
}
}}
}
示例4: printResult
void printResult(const linearProgramming::SlackForm& condition, const vc& sign, bool f = true)
{
auto vars = condition.getResult();
for (size_t i = 0, k = 0; i < sign.size(); ++i)
{
if (sign[i] == '+')
{
cout << vars[k++];
}
else
{
cout << vars[k] - vars[k + 1] << endl;
}
cout << "\t";
}
cout << endl;
if (f)
{
cout << "MAX = " << condition.getV() << endl;
}
else
{
cout << "MAX = " << -condition.getV() << endl;
}
}
示例5: 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();
}
}
示例6: fft
//el vector a debe ser de una longitud potencia de 2
//mult = 1 FFt
//mult = -1 lo usa el inv_fft
//el vector a debe ser de una longitud potencia de 2
//mult = 1 FFt
//mult = -1 lo usa el inv_fft
vc fft(vc &a){
int n = a.size();
vc y(n);
int lg = 0;
while((1<<lg)<n) lg++;
for(int i=0;i<n;i++){
y[rev(i,lg)]=a[i];
}
for(int i = 1; i <= lg; i++){
int m = 1<<i;
for(int k=0;k<n;k+=m){
for(int j=0;j<m/2;j++){
double angle = (mult*j*2.0*M_PI)/m;
comp w = comp(cos(angle),sin(angle));;
comp t = w * y[k+j+m/2];
comp u = y[k+j];
y[k+j]=u+t;
y[k+j+m/2]=u-t;
}
}
}
return y;
}
示例7: 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;
}
}
示例8: check
bool check(vc ckset){
int qw = 0;
for (int i = 0; i < ckset.size()-1; i++) {
if (ckset[i]%12 == 0 || ckset[i] == 12) {
qw++;
}
}
if (qw == 9) {
return true;
}
return false;
}
示例9: 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);
}
示例10: 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;
}
示例11: 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;
}
示例12: transform
vc transform(int code, vc vec){
int size = vec.size();
vc initial = vec;
switch(code){
case 1:
for (int i=0; i<size; ++i){
for (int j=0; j<size; ++j){
vec[j][size-i-1] = initial[i][j];
}
}
return vec;
break;
case 4:
for (int i=0; i<size; ++i){
for (int j=0; j<size; ++j){
vec[i][size-j-1] = initial[i][j];
}
}
return vec;
break;
case 3:
for (int i=0; i<size; ++i){
for (int j=0; j<size; ++j){
vec[size-j-1][i] = initial[i][j];
}
}
return vec;
break;
case 2:
for (int i=0; i<size; ++i){
for (int j=0; j<size; ++j){
vec[size-i-1][size-j-1] = initial[i][j];
}
}
return vec;
break;
}
}
示例13: 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#>)
}
}
}
示例14: 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);
}
}
示例15: 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';
}