当前位置: 首页>>代码示例>>C++>>正文


C++ IV::end方法代码示例

本文整理汇总了C++中IV::end方法的典型用法代码示例。如果您正苦于以下问题:C++ IV::end方法的具体用法?C++ IV::end怎么用?C++ IV::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IV的用法示例。


在下文中一共展示了IV::end方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: f

// Returns the number of containers required to move all the milk, with at
// most "c" in each container
int f(int c)
{
    int ret = 0;
    IVi it = acap.begin();

    int lim = c;
    while (true) {
        if (*it > lim) return INF;
        it = upper_bound(it, acap.end(), lim);
        ++ret;
        if (it == acap.end()) return ret;
        lim = *(it - 1) + c;
    }
    return -1;
}
开发者ID:asifcse10,项目名称:pc-code,代码行数:17,代码来源:fill.cpp

示例2: main

int main()
{
	prime_sieve ( );
	int x, ok;
	while ( scanf ( "%d", &x ) != EOF ) {
		ok = 1;
		if ( x < 5 ) printf ( "%d is not the sum of two primes!\n", x );
		else if ( x & 1 ) {
			if ( is_prime(x-2) ) printf ( "%d is the sum of %d and %d.\n", x, 2, x-2 );
			else printf ( "%d is not the sum of two primes!\n", x );
		}
		else {
			IV :: iterator it = upper_bound ( primes.begin(), primes.end(), x/2 );
			for ( ; it != primes.end(); ++it )
				if ( is_prime(x-*it) ) {
					printf ( "%d is the sum of %d and %d.\n", x, x-*it, *it );
					ok = 0;
					break;
				}
			if ( ok ) printf ( "%d is not the sum of two primes!\n", x );
		}
	}
    return 0;
}
开发者ID:Accoral,项目名称:uva,代码行数:24,代码来源:10311.cpp

示例3: main

int main()
{
	//cout << sqrt ( 1000 ) << endl;
	prime_sieve ( );
	int n, c, from, to, len, i;
	while ( scanf ( "%d%d", &n, &c ) != EOF ) {
		printf ( "%d %d:", n, c );
		len = upper_bound ( primes.begin(), primes.end(), n ) - primes.begin();
		if ( len&1 ) from = len/2-(c-1), to = len/2+(c-1);
		else from = len/2-c, to = len/2+(c-1);
		from = max ( 0, from ); to = min ( len-1, to );
		for ( i = from; i < to; ++i ) printf ( " %d", primes[i] );
		printf ( " %d\n\n", primes[i] );
	}
    return 0;
}
开发者ID:Accoral,项目名称:uva,代码行数:16,代码来源:406.cpp

示例4: test_case

void test_case()
{
    int n = rand() % (MAXN - 2) + 3;
    int MaxEdges = min(n*(n-1)/2, MAXM);
    int m = rand() % (MaxEdges + 1);

    if (m < n - 1) m = n - 1;

    printf("\n%d %d\n", n, m);

    IV ls;
    IIS s;
    for (int i = 0; i < n; ++i)
        ls.push_back(i);
    random_shuffle(ls.begin(), ls.end());

    printf("%d %d\n", ls[0], ls[1]); --m;
    int u = ls[0], v = ls[1];
    if (u > v) swap(u, v);
    s.insert(II(u, v));

    for (int i = 2; i < n; ++i) {
        u = ls[rand() % i], v = ls[i];
        printf("%d %d\n", u, v); --m;
        if (u > v) swap(u, v);
        s.insert(II(u, v));
    }

    while (m--) {
        int u, v;
        do {
            u = rand() % n;
            v = rand() % n;
            if (u > v) swap(u, v);
        } while (u == v || s.find(II(u, v)) != s.end());

        s.insert(II(u, v));

        if (rand() % 2 == 0) swap(u, v);
        printf("%d %d\n", u, v);
    }
}
开发者ID:M4573R,项目名称:pc-code,代码行数:42,代码来源:gen.cpp


注:本文中的IV::end方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。