The basics of programming in c++ for beginners

Tasks and solution. С

  1. Data types, variables and constants
  2. Ввод с клавиатуры и вывод данных на экран
  3. Арифметические операции и комбинированные операторы
  4. Операторы выбора if и else в С
  5. The switch statement in C ++
  6. The for loop in C++
  7. Циклы while, do while, nested loops
  8. Two-dimensional arrays C ++
  9. Arrays in C++
  10. Functions in C++
  11. Pointers C ++
  12. A pointer to a pointer to C ++
  13. Classes in C ++

Additional collection of problems with solutions

практика программирования, задачи с решением, задачи по программированию с++, задачи по программированию C++

This page contains all of the tasks on the topics lessons, posted on our website. К каждой задаче прилагается наш вариант решения. Постарайтесь всё же решать их самостоятельно и только потом сравнивать наш исходный код со своим. “Хочешь научиться программировать – программируй”!

Больше практических заданий с решениями найдёте here.

Рекомендуем посетить Сайт для юных программистов – где вы найдете уроки по различным языкам программирования (в том числе для детей), 3D-моделированию, Linux и др.

127 thoughts on “Tasks and solution. С

  1. lovely Elephants

    prb4715 In one Indian village teacher asked the boy Manmohan count the number of elephants in the village. Manmohan counted all the elephants in the village, and he got a two-digit number n. But instead of, to report the answer to the teacher, Manmohan has decided to play a trick bit. For this Manmohan subtracted from the resulting sum the number of its digits, I divide the result by 9 (rejecting at the same fractional part of the result), that number increased to 1, then append to the end of the last digit obtained starting from the result subtracted chislani 10. Then, what happened in the end, he told the teacher.

    Despite all the cunning Manmohan, teacher could determine the number of resulting, how many elephants were in the village. Identify it and you.

    Input data

    Целое число, which received Manmohan.

    Output

    Print the number of elephants in the village.

    1. Thank you, for homework. I worked the brain) The decision take off below:
      // The solution of the problem
      manhomannumb + = 10;
      b = manhomannumb %10;
      teachernumb = manhomannumb;
      teachernumb /= 10;
      teachernumb –;
      teachernumb *= 9;
      while (teachernumb % 10 != 0) teachernumb++;
      teachernumb += b;
      cout << "Учитель посчитал. Elephant Village: "<< teachernumb << endl;
      system("pause");
      return 0;
      }

      Thanks again)

      1. Atvichayu there is an option much easier:
        #include
        int main(){ int n;
        std::cin >> n;
        std::cout << n;}

    2. // Chapter Objectives 1. A task 1.36
      // Space between numbers
      #include “pch.h”
      #include
      using namespace std;

      int main()
      {
      int tnum, drink, dec, one;
      setlocale(LC_ALL, “Russian”);
      cout <> tnum;
      {
      Dec = tnum / 10; //Break numbers into digits
      Mnum = tnum % 10;
      one = mnum / 1;

      mnum = dec + one; //Manmohan subtracted the sum of its digits from the resulting number
      Mnum = tnum – drink;
      mnum = mnum / 9; //I divide the result by 9 (rejecting at the same fractional part of the result)
      mnum = mnum + 1; //that number increased to 1
      mnum = mnum * 10 + one; //added the last digit of the original number to the end of the received number
      mnum = mnum – 10; //and subtracted from the result 10
      cout << " Teacher elephants: " << tnum << " Manmohan number: " << drink << endl;
      return 0;
      }
      }
      //—————————————————————————

      1. #include “pch.h”
        #include
        using namespace std;

        int main()
        {
        int tnum, drink, dec, one;
        setlocale(LC_ALL, “Russian”);
        cout <> tnum;
        {
        Dec = tnum / 10; //Break numbers into digits
        Mnum = tnum % 10;
        one = mnum / 1;

        mnum = dec + one; //Manmohan subtracted the sum of its digits from the resulting number
        Mnum = tnum – drink;
        mnum = mnum / 9; //I divide the result by 9 (rejecting at the same fractional part of the result)
        mnum = mnum + 1; //that number increased to 1
        mnum = mnum * 10 + one; //added the last digit of the original number to the end of the received number
        mnum = mnum – 10; //and subtracted from the result 10
        cout << " Teacher elephants: " << tnum << " Manmohan number: " << drink << endl;
        return 0;
        }
        }
        //—————————————————————————

  2. help me please “Classes begin in n hours m minutes,and ends at a clock k hvydyn.Skilky hours and minutes long zahyattya

    1. Move all in minutes, Vienna, and then find a result from Dillen – years, the balance – moments

    2. I haven't studied C ++, decided something like this:

      #include “pch.h”
      #include
      #include
      using namespace std;

      int main()
      {
      int n, m, k, a;
      setlocale(LC_ALL, “Russian”);

      cout << "Занятия начинаются в:" <> n;
      if (n >= 24) {
      cout << "ERROR1: CRITICAL VALUE: NO MORE THAN 24 HOURS IN A DAY!(from 0 to 23)" <> m;
      }
      if (m >= 60) {
      cout << "ERROR2: CRITICAL VALUE: NO MORE THAN 60 MINUTES IN AN HOUR!(from 0 to 59)" << endl;
      return 0;
      }
      else
      {
      cout << "Занятия заканчиваются в:" <> k;
      if (k >= 24) {
      cout << "ERROR1: CRITICAL VALUE: NO MORE THAN 24 HOURS IN A DAY!(from 0 to 23)" <> a;
      }
      if (a >= 60) {
      cout << "ERROR2: CRITICAL VALUE: NO MORE THAN 60 MINUTES IN AN HOUR!(from 0 to 59)" << endl;
      return 0;
      }
      else {
      n = k – n;
      m = a – m;
      if (n < 0) {
      cout << "ERROR3: ВНИМАНИЕ: CLASSES CANNOT LAST MORE DAYS!" << endl;
      return 0;
      }
      else if (m < 0) {
      n = n – 1;
      m = abs(m);
      }
      {
      cout << "Занятия закончатся через:" << n << ":" << m << endl;
      return 0;
      }
      }
      }
      }

  3. You can help very urgently needed “In the beauty salon come girls n. Each of them should visit the hairdresser and beautician. Everyone she spends hours on m. During that time the smallest k salon staff will serve all girls, If each employee can serve as a cosmetologist, and the hairdresser?”

  4. Help please Proteins saryatali in the hollow N nuts. Every day they took half for yourself and your friends. If the number of nuts was odd that they put off a nut in the direction and the other half dilili,wherein the nut deferred again returned into the hollow. Write a program, podschitvayuschuyu,many nuts remain in the bag by K days?

    1. #include
      using namespace std;
      int main()
      {
      int N, K;
      cin >> N >> K;
      for(K; K>0; K–){
      if(N%2==1 and N!=1) N=(N/2)+1;
      presence of N = N / 2;
      }
      cout << N;
      }

      1. help me please: write program code to solve the problem. The triangle vertex coordinates set A (0;0), At (and, and 1), Exist (-and, i + 1), and = 9. Calculate the height Ha of the inscribed circle and the radius r.

  5. help me please: write program code to solve the problem. Triangle asked the coordinates of the vertices A (0;0), At (and, and 1), Exist (-and, and +1), and 9 =. Calculate the height Ha and inscribed circle radius r.

  6. help me please: write program code to solve the problem. The triangle vertex coordinates set A (0;0), At (and, and 1), Exist (-and, i + 1), and = 9. Calculate the height Ha of the inscribed circle and the radius r.

      1. Perform all tasks of a theoretical part and debug the reduced program

Leave a Reply

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