int i = 100, x = 0, y = 0; while (i > 0) {
i--;
x = i % 8; if (x == 1)
y++;
}
cout << y << endl; return 0; }
Êä³ö£º_________
3. #include
using namespace std;
int main() {
int a[6] = {1, 2, 3, 4, 5, 6}; int pi = 0; int pj = 5; int t , i;
while (pi < pj)
{ t = a[pi]; a[pi] = a[pj]; a[pj] = t; pi++; pj--; }
for (i = 0; i < 6; i++)
cout << a[i] << \cout << endl; return 0; }
Êä³ö£º_________
4. #include
using namespace std;
int main() {
int i, length1, length2; string s1, s2;
s1 = \
CCF NOIP2016 ³õÈüÆÕ¼°×é C++ÓïÑÔÊÔÌâ
µÚ 6 Ò³£¬¹² 9 Ò³
s2 = \length1 = s1.size(); length2 = s2.size();
for (i = 0; i < length1; i++)
if (s1[i] >= 'a' && s1[i] <= 'z')
s1[i] -= 'a' - 'A';
for (i = 0; i < length2; i++)
if (s2[i] >= 'a' && s2[i] <= 'z')
s2[i] -= 'a' - 'A';
if (s1 == s2)
cout << \else if (s1 > s2)
cout << \else
cout << \return 0; }
Êä³ö£º_________
ËÄ¡¢ÍêÉÆ³ÌÐò£¨¹² 2 Ì⣬ÿÌâ 14 ·Ö£¬¹²¼Æ 28 ·Ö£©
1. £¨¶ÁÈëÕûÊý£©ÇëÍêÉÆÏÂÃæµÄ³ÌÐò£¬Ê¹µÃ³ÌÐòÄܹ»¶ÁÈëÁ½¸ö int ·¶Î§ÄÚµÄÕûÊý£¬
²¢½«ÕâÁ½¸öÕûÊý·Ö±ðÊä³ö£¬Ã¿ÐÐÒ»¸ö¡££¨µÚÒ»¡¢Îå¿Õ 2.5 ·Ö£¬ÆäÓà 3 ·Ö£©
ÊäÈëµÄÕûÊýÖ®¼äºÍǰºóÖ»»á³öÏÖ¿Õ¸ñ»òÕ߻سµ¡£ÊäÈëÊý¾Ý±£Ö¤ºÏ·¨¡£
ÀýÈ磺
ÊäÈ룺
123 -789
Êä³ö£º
123
-789
#include
int readint() {
int num = 0; // ´æ´¢¶ÁÈ¡µ½µÄÕûÊý int negative = 0; // ¸ºÊý±êʶ char c; // ´æ´¢µ±Ç°¶ÁÈ¡µ½µÄ×Ö·û c = cin.get();
while ((c < '0' || c > '9') && c != '-')
c = (1) ;
CCF NOIP2016 ³õÈüÆÕ¼°×é C++ÓïÑÔÊÔÌâ
µÚ 7 Ò³£¬¹² 9 Ò³
if (c == '-')
negative = 1; else
(2) ;
c = cin.get(); while ( (3) ) {
(4) ; c = cin.get(); }
if (negative == 1)
(5) ;
return num; }
int main()
{ int a, b;
a = readint(); b = readint();
cout << a << endl << b << endl; return 0; }
2. £¨½¼Óλ£©ÓÐ n Ãûͬѧ²Î¼ÓѧУ×éÖ¯µÄ½¼Óλ£¬ÒÑ֪ѧУ¸øÕâ n Ãûͬѧ
µÄ½¼ÓÎ×ܾ·ÑΪ A Ôª£¬Óë´ËͬʱµÚ i λͬѧ×Ô¼ºÐ¯´øÁË Mi Ôª¡£ÎªÁË·½±ã½¼ ÓΣ¬»î¶¯µØµãÌṩ B(¡Ýn)Á¾×ÔÐгµ¹©ÈË×âÓã¬×âÓÃµÚ j Á¾×ÔÐгµµÄ¼Û¸ñΪ Cj Ôª£¬Ã¿Î»Í¬Ñ§¿ÉÒÔʹÓÃ×Ô¼ºÐ¯´øµÄÇ®»òÕßѧУµÄ½¼Óξ·Ñ£¬ÎªÁË·½±ãÕËÎñ¹Ü Àí£¬Ã¿Î»Í¬Ñ§Ö»ÄÜΪ×Ô¼º×âÓÃ×ÔÐгµ£¬ÇÒ²»»á½èÇ®¸øËûÈË£¬ËûÃÇÏëÖªµÀ×î¶à ÓжàÉÙλͬѧÄܹ»×âÓõ½×ÔÐгµ¡££¨µÚËÄ¡¢Îå¿Õ 2.5 ·Ö£¬ÆäÓà 3 ·Ö£©
±¾Ìâ²ÉÓöþ·Ö·¨¡£¶ÔÓÚÇø¼ä[l, r]£¬ÎÒÃÇÈ¡Öмäµã mid ²¢ÅжÏ×âÓõ½×ÔÐÐ ³µµÄÈËÊýÄÜ·ñ´ïµ½ mid¡£ÅжϵĹý³ÌÊÇÀûÓÃ̰ÐÄË㷨ʵÏֵġ£ #include
int n, B, A, M[MAXN], C[MAXN], l, r, ans, mid; bool check(int nn)
{ int count = 0, i, j; i = (1) ; j = 1; while (i <= n) { if ( (2) )
CCF NOIP2016 ³õÈüÆÕ¼°×é C++ÓïÑÔÊÔÌâ
µÚ 8 Ò³£¬¹² 9 Ò³
count += C[j] - M[i]; i++; j++; } return (3) ;
}
void sort(int a[], int l, int r) {
int i = l, j = r, x = a[(l + r) / 2], y; while (i <= j) {
while (a[i] < x) i++; while (a[j] > x) j--; if (i <= j) {
y = a[i]; a[i] = a[j]; a[j] = y; i++; j--;
}
}
if (i < r) sort(a, i, r); if (l < j) sort(a, l, j); }
int main() { int i;
cin >> n >> B >> A;
for (i = 1; i <= n; i++) cin >>
M[i];
for (i = 1; i <= B; i++) cin >>
C[i];
sort(M, 1, n); sort(C, 1, B); l = 0;
r = n;
while (l <= r) {
mid = (l + r) / 2;
if ( (4) ) {
ans = mid;
l = mid + 1;
} else
r = (5) ;
}
cout << ans << endl; return 0; }
CCF NOIP2016 ³õÈüÆÕ¼°×é C++ÓïÑÔÊÔÌâ µÚ 9 Ò³£¬¹² 9 Ò³
µÚ¶þÊ®¶þ½ìÈ«¹úÇàÉÙÄêÐÅϢѧ°ÂÁÖÆ¥¿ËÁªÈü³õÈü
ÆÕ¼°×é²Î¿¼´ð°¸
Ò»£®Ñ¡ÔñÌâ
DCDCD CBBCA DBDAD BAACC ¶þ£®ÎÊÌâÇó½â 1. 72
2. 1£¨2·Ö£© 11£¨3·Ö£© Èý£®ÔĶÁ³ÌÐòд½á¹û 1. 6,1,3 2. 13
3. 6,5,4,3,2,1, 4. =
ËÄ£®ÍêÉÆ³ÌÐò 1.
(1)cin.get()
(2)num=c-¡®0¡¯ »ò num=c-48
(3)c>=¡¯0¡¯&&c<=¡¯9¡¯ »ò c>=48&&c<=57 (4) num=num*10+c-'0' »ò num=num*10+c-48 (5) num=-num »ò return-num 2.
(1) n-nn+1
(2) M[i]