Программирование на языке C++ - ответы
Количество вопросов - 322
class Foo { const int I; static void Init(int x); void Setup(int x = 0) const; public: Foo(int x = 0); };
#include <stdio.h>main(){ int a[3][4]; int i, j, k; for (i = 0; i < 3; i++) for (j = 0; j < 4; j++) scanf("%d",&a[i][j]); for (i = 0; i < 3; i++) { k = 0; for (j = 0; j < 4; j++) if (a[i][j] > 0) ++k; } printf("%d",k);}
#include <stdio.h>void f(char* a, char* const b){ a[0] = b[0]; b[1] = a[1];}int main(){ char a[]="abcd"; char b[]= "opr"; f(a,b); printf ("%s%s", a, b); return 0;}
class Foo{int x;public: Foo(int i){}};class Bar: virtual Foo{public: Bar(){}};Bar b;
int k;float y;int main(){ k = 4; y = 2; printf ("%4.2f%2d", y, k); return 0;}
#include <stdio.h>void f(char a, char d){ a = d; d = a;}int main(){ char a[] = "глаз"; f(a[0],a[3]); puts(a); return 0;}
A = 2;if (В <= 4)C = 1;elseC = 0;A = C;
a = 1;if ((b < 0) || (b > 1)) a = 3;if (b > 5) a = 5;
a = 1;if ((b > 0) && (b < 2)) a = 3;if (b > 5) a = 5;
main(){int k;int m;k = 3; m = 0;while (k < 3){ ++k; ++m;}}
main(){int k;int m;m = 0;for (k = 1; k <= 2; k++) ++m; ++m;}
for (int ii = 0; ii < 3; ++ ii){ switch (ii) { case 0: cout << "ZERO"; case 1: cout << "ONE"; continue; case 2: cout << "TWO"; break; } cout << endl;}
#include <stdio.h>#include <math.h>int main(){const int a[8] = {3,8,0,-6,0,-1,-9,3};int i,k; k = abs(a[7]); for (i = 0; i< 8; i++) { if (abs(a[i]) > k) k = abs(a[i]); printf("%d",k); }}
#include <stdio.h>#include <math.h>main(){const int a[8] = {3,8,0,-6,0,-1,-9,3};int i,k; k = abs(a[7]); for (i = 0; i < 8; i++) if (abs(a[i]) < k) k = abs(a[i]); printf("%d",k);}
#include <stdio.h>#include <math.h>main(){const int a[8] = {3,8,0,-6,0,-1,-9,3};int i,j,k; k = 0; j = 4; for (i = 0; i < 8; i++) if (abs(a[i]) > j) ++k; printf("%d",k);}
#include <stdio.h>main(){const int a[8] = {3,8,0,-6,0,-1,-9,3};int i,j,k; k = 0; j = 2; for (i = 0; i < 8; i++) if (a[i] < j) ++k; printf("%d",k);}
#include <stdio.h>main(){const char a[] = "abcrcaab";int i; char k;k = 'b';for (i = 0; i < 8; i++)if (a[i] > k) k = a[i];printf("%c",k);}
#include <stdio.h>main(){const char a[] = "abcrcaab";int i; char k; k = 'c'; for (i = 0; i < 8; i++) if (a[i] <= k) { k = a[i]; printf("%c",k); }}
#include <stdio.h>main(){ const char a[] = "abcrcaab"; int i; char k; k = a[0]; for (i = 1; i < 8; i++) if (a[i] < k) k = a[i]; printf("%c",k);}
#include <stdio.h>main(){ const char a[] = "abcra"; int i; char k; k = 'c'; for (i = 1; i < 5; i++) { if (a[i] < k) k = a[i]; printf("%c",k); }}
#include <stdio.h>int a, b, c, d;void f( int a, int& c, int& d){int b; a = 5; c = 7; b = 9;}int main(){ a = 1; c = 1; b = 1; f(b,a,c); printf ("%d|%d|%d",a,c,b); return 0;}
class Class1 { public: void func(); }; void (Class1::*pmfn)() = &Class1::func; Class1 *c;
class Base{ public: Base(int _x=10){x=_x;} virtual void f() {cout<<x*2<<endl;} protected: int x;};class Derived: public Base{ public: void f() {cout<<x/2<<endl;}};int main(){ Derived d; Base* pB= &d; pB->f(); return 0;
int main(){int k;int m;m = 1;for (k = 3; k >= 1; k--)++m;}
A = 2;if (В <= 4)C = 1;else { C = 0;A = C;}
#include <stdio.h>const char a[] = "abcra";int i; char k;main(){ k = 'c'; for (i = 1; i < 5; i++) if (a[i] < k) { k = a[i]; printf("%c",k); }}
#include <stdio.h>main(){const char a[] = "abcrcaab";int i;for (i = 7; i > 1; i--) if (a[i] < 'c') printf("%c",a[i]);}
int main (){int k;int m;k = 0; m = 0;while (k < 3)++k;++m;return m;}
class Base{ int b; protected: int c; public: int d;};class Derived: Base{ friend class Friend; int e;};class Friend{ Derived derived;};
#include <iostream.h>class A{int x;public:A(int y){x = y;}};int main(){ A a(3); cout << a.x << endl; return 0;}
class Foo { char *buf; public: Foo(char *b = "default") { buf = new char[strlen(b) + 1]; strcpy(buf, b); } ~Foo() { delete[] buf; } }; Foo Func(Foo f) { return f; }
#include <stdio.h>main(){ int a[3][4]; int i, j, k; for (i = 0; i < 3; i++) for (j = 0; j < 4; j++) scanf("%d", &a[i][j]); k = -1; for (i = 0; i < 4; i++) { for (j = 0; j < 3; j++) if (a[j][i] == 0) { k = i; break; } } printf("%d",k);}
#include <stdio.h>main(){const char a[] = "abcrcaab";int i; char k; k = 'a'; for (i = 0; i < 8; i++) if (a[i] > k) { k = a[i]; printf("%c",k); }}
#include <stdio.h>main(){const int a[8] = {3,8,0,-6,0,-1,-9,3};int i,k; k = 1; for (i = 7; i >= 0; i--) if (a[i] == 0) k = i; printf("%d",k);}
#include main() { int i; float t; i = 1; t = 5; printf("%3.1f%d%2d", t, i, i); }
#include main() { int i; float t; i = 2; t= 2; printf("%4.1f%2d%d", t, i, i); }
a = 1;if (b < 1) a = 2;if (b > 5) a = 3;
main(){int k;int m;m = 1;for (k = 1; k <= 2; k++) {++m; k+=2; }}
#include <stdio.h>#include <math.h>main(){const int a[8] = {3,8,0,-6,0,-1,-9,3};int i,j,k; k = 0; j = 4; for (i = 0; i < 8; i++) if (abs(a[i]) > j) k = a[i]; printf("%d",k);}
#include <stdio.h>main(){const char a[] = "abcrcaab";int i; char k; k = 'b'; for (i = 0; i < 8; i++) if (a[i] < k) printf("%c",k);}
#include <stdio.h>main(){const char a[] = "abcrcaab";int i; for (i = 0; i < 8; i++) if ((a[i] > 'a') && (a[i] < 'c'))printf("%c",a[i]);}
#include <stdio.h>int a, b, c, d;void f( int& a, int c, int& d){int b; a = 5; c = 7; b = 9;}int main(){ a = 1; c = 1; b = 1; f(a,b,c); printf ("%d|%d|%d",a,c,b); return 0;}
#include <stdio.h>void f(char a, char& d){ a = 'в'; d = 'с';}int main(){ char a[]="глаз"; f(a[0],a[3]); puts(a); return 0;}
#include <stdio.h>void f(char* a, char* b){ a = b; b = a;}int main(){ char a[]="abcde"; char b[]= "opr"; f(a,b); puts(a); return 0;}
#include <stdio.h>void f(char* a, char* b){ a[1] = b[1]; b[2] = a[2];}int main(){ char a[]="abcd"; char b[]= "opr"; f(a,b); printf ("%s%s", a, b); return 0;}
class myclass { int a;public: myclass(int x); }; myclass::myclass(int x) { a = x;} int main() { myclass ob(120); myclass *p; return 0; }
class Base{ int a; public: int b; protected: int c;};class Derived: Base{ friend class Friend; int d;};class Friend{ Derived derived;};
class basex { int x; public: void setx(int y) {x = y;} }; class derived : basex {};
class mybase {}; class derived1 {}; class derived2:public mybase,derived1{};
#include <stdio.h>const char a[] = "abcra";int i; char k;main(){ k = 'c'; for (i = 1; i < 5; i++) if (a[i] >= k) { k = a[i]; printf("%c",k); }}
#include <stdio.h>main(){const int a[8] = {3,8,0,-6,0,-1,-9,3};int i,k; k = a[0]; for (i = 1; i < 8; i++) if (a[i] > k) k = a[i]; printf("%d",k);}
#include <stdio.h>void f(char* a, char* b){ char* c; c = a; a = b; b = c;}int main(){ char a[]="abc"; char b[]= "pr"; f(a,b); printf ("%s%s", a, b); return 0;}
class Base{ public: Base(int _x = 10){x = _x;} void f() {cout<<x*2<<endl;} protected: int x;};class Derived: public Base{ public: void f() {cout<<x/2<<endl;} };int main(){ Derived d; Base* pB= &d; pB->f(); return 0;}
class SomeClass { int x; public: SomeClass (int xx) : x(xx) {}; }; SomeClass x (10); SomeClass y(x);
class basex { protected: int x; }; class derived : private basex {};
main(){int k;int m; k = 3; m = 0; while (k > 0){ k--; m++; }}
a = 1;if ((b > 0) && (b < 3)) a = 3; elseif (b > 5) a = 5;
#include <stdio.h>int a, b, c, d;void f( int a, int& c, int& d){int b; a = 5; c = 7; b = 9;}int main(){ a = 1; c = 1; b = 1; f(a,c,b); printf ("%d|%d|%d",a,c,b); return 0;}
if (В <= 4)C = 1;else C = 0;A = C;
main(){int k;int m; k = 3; m = 0; while (k > 0)--k;++m;}
#include <stdio.h>#include <math.h>main(){const int a[8] = {3,8,0,-6,0,-1,-9,3};int i,k; k = abs(a[7]); for (i = 0; i < 8; i++) if (abs(a[i]) > k) k = a[i]; printf("%d",k);}
#include <stdio.h>#include <math.h>int main(){const int a[8] = {3,8,0,-6,0,-1,-9,3};int i,j,k; k = 0; j = 4; for (i = 0; i < 8; i++) if (a[i] > j) k = abs(a[i]); printf("%d",k);}
#include <stdio.h>void f(char& a, char d){ a = 'в'; d = 'д';}int main(){ char a[] = "глаз"; f(a[0],a[3]); puts(a); return 0;}
#include <iostream.h>class A{int x;public:A(int y){x = y;}};int main(){ A a; cin >> a.x; return 0;}
struct Foo { int f1() { return 0; } int f2(); }; int Foo::f2() { return 0; };
class A {// ... }; class B : ??? A {}; class C : public B {};
class Base{ public: void f() {cout<<"111"<<endl;}};class Derived: public Base{ public: void f() {cout<<"222"<<endl;}};int main(){ Base* ptr= new Derived; ptr->f(); return 0;}
#include <stdio.h>main(){const char a[] = "abcrcaab";int i; for (i = 0; i < 8; i++) if (a[i] < 'c') printf("%c",a[i]);}
main(){int k;int m;m = 1;for (k = 3; k >= 1; k--) ++m;}
#include <stdio.h>main(){const int a[8] = {3,8,0,-6,0,-1,-9,3};int i,k; k = 1; for (i = 0; i < 8; i++) if (a[i] == 0) k = i; printf("%d",k);}
A = 2;if (В <= 4) { C = 1;}else {C = 0;A = C;}
for (int ii = 0; ii < 3; ++ ii) { switch (ii) { case 0: cout << "ZERO"; break; case 1: cout << "ONE"; case 2: cout << "TWO"; continue; } cout << endl; }
#include <stdio.h>#include <math.h>main(){const int a[8] = {3,8,0,-6,0,-1,-9,3};int i,k; k = abs(a[7]); for (i = 0; i< 8; i++) if (abs(a[i]) > k) k = abs(a[i])- 2; printf("%d",k);}
#include <stdio.h>main(){ int a[3][4]; int i, j, k; for (i = 0; i < 3; i++) for (j = 0; j < 4; j++) scanf("%d", &a[i][j]); for (i = 0; i < 4; i++) { k = 0; for (j = 0; j < 3; j++) if (a[j][i] > 0) ++k; } printf("%d",k);}
#include <stdio.h>int a, b, c, d;void f( int& a, int& c, int& d){int b; a = 5; c = 7; b = 9;}int main(){ a = 1; c = 1; b = 1; f(a, b, c); printf ("%d|%d|%d",a,c,b); return 0;}
class Base{ public: int a; protected: int b; private: int c;};class Derived: Base{ friend class Friend; int d;};class Friend{ Derived derived;};
class basex { public: int x; }; class derived : basex {};
class basex { int x; public: void setx(int y) {x = y;} }; class derived : public basex {};
#include <stdio.h>main(){ int a[3][4]; int i, j, k; for (i = 0; i < 3; i++) for (j = 0; j < 4; j++) scanf("%d", &a[i][j]); k = -1; for (i = 0; i < 4; i++) { for (j = 0; j < 3; j++) if (a[j][i] == 0) k = i; } printf("%d",k);}
#include <stdio.h>main() { int k; float x; k = 2; x = 3; printf("[%4.2f%d]", x, k); }
namespace f { struct Obj { struct T; template<class T, class f> virtual void f() { } }; };
#include <stdio.h>main(){ const char a[] = "abcrcaab"; int i; char k; k = a[0]; for (i = 1; i < 8; i++) if (a[i] <= k) k = a[i]; printf("%c",k);}
#include <stdio.h>#include <math.h>main(){const int a[8] = {3,8,0,-6,0,-1,-9,3};int i,k; k = abs(a[2]); for (i = 0; i < 8; i++) if (a[i] > k) k = abs(a[i])- 2; printf("%d",k);}
#include <stdio.h>void f(char& a, char d){ a = d; d = a;}int main(){ char a[] = "глаз"; f(a[0],a[3]); puts(a); return 0;}
class Base{ public: virtual void f() {cout<<"111"<<endl;}};class Derived: public Base{ public: void f() {cout<<"222"<<endl;}};int main(){ Base* ptr= new Derived; ptr->f(); return 0;}
class basex { protected: int x; }; class derived : public basex {};
class basex { public: int x; }; class derived : protected basex {};
class basex { protected: int x; }; class derived : protected basex {};