The basics of programming in c++ for beginners

A task: To add one to the number

With the keyboard a positive integer is entered, in decimal notation is added to the beginning and the end of the figure 1 (for example: 478->14781). As a result, to determine, Is it a simple number?

Decision:

Result:

problem with C ++ solution, c ++ beginners

3 thoughts on “A task: To add one to the number

  1. Not really understand the decision on the site made its .
    #include
    #include
    using namespace std;
    bool foo( int n) {
    if (!(n % 2)) return false;
    for ( int i = 3; i * i > F;
    strcat_s(A, F);
    strcat_s(A, B);
    cout << A << endl;
    int g;
    g = strlen(A);
    you * pa = new you[g] {};
    you e = 0;
    for (int i = 0; i < g; i ) {
    however,[i] = A[e];
    e++;
    }
    for (int i = 0; i < g; i ) {
    switch (however,[i]) {
    case 48:
    however,[i] = 0;
    break;
    case 49:
    however,[i] = 1;
    break;
    case 50:
    however,[i] = 2;
    break;
    case 51:
    however,[i] = 3;
    break;
    case 52:
    however,[i] = 4;
    break;
    case 53:
    however,[i] = 5;
    break;
    case 54:
    however,[i] = 6;
    break;
    case 55:
    however,[i] = 7;
    break;
    case 56:
    however,[i] = 8;
    break;
    case 57:
    however,[i] = 9;
    break;
    }
    }
    int t = 1;
    for (int i = 0; i < g-1; i ) {
    t *= 10;
    }
    int x = 0;
    for (int i = 0; i < g; i ) {
    x += pa[i] * t;
    t /= 10;
    }
    cout <<endl<< x;
    cout << "число: " << (foo(x) ? " " : " не ")<< "простое" << endl;

    }

  2. #include

    #include
    using namespace std;
    bool foo( int n) {

    for (int i = 2; i > F;
    strcat_s(A, F);
    strcat_s(A, B);
    cout << A << endl;
    int g;
    g = strlen(A);
    you * pa = new you[g] {};
    you e = 0;
    for (int i = 0; i < g; i ) {
    however,[i] = A[e];
    e++;
    }
    for (int i = 0; i < g; i ) {
    switch (however,[i]) {
    case 48:
    however,[i] = 0;
    break;
    case 49:
    however,[i] = 1;
    break;
    case 50:
    however,[i] = 2;
    break;
    case 51:
    however,[i] = 3;
    break;
    case 52:
    however,[i] = 4;
    break;
    case 53:
    however,[i] = 5;
    break;
    case 54:
    however,[i] = 6;
    break;
    case 55:
    however,[i] = 7;
    break;
    case 56:
    however,[i] = 8;
    break;
    case 57:
    however,[i] = 9;
    break;
    }
    }
    int t = 1;
    for (int i = 0; i < g-1; i ) {
    t *= 10;
    }
    int x = 0;
    for (int i = 0; i < g; i ) {
    x += pa[i] * t;
    t /= 10;
    }
    cout <<endl<< x;
    cout << "число: " << (foo(x) ? " " : " не ")<< "простое" << endl;

    }

  3. #include

    using namespace std;

    int main() {
    int z, v, c;
    int i = 0;

    cout <> from;
    int o = z;
    while (from > 0) {
    z /= 10;
    i ;
    }
    c = 1;
    for (int v = 1; v <= i; v++) {
    c *= 10;

    }
    int d = c + O;
    int x = d * 10 + 1;
    cout << x << " – ";
    for (int i = 2; i < x; ++i) {
    if (x % i == 0) {
    cout << " не простое число ";
    break;
    } else {
    cout << "простое число ";
    break;
    }
    }

    return 0;
    }

Leave a Reply

Your email address will not be published. Required fields are marked *