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 и др.

134 thoughts on “Tasks and solution. С

  1. Help solve the problem in C ++ : “Known area circumscribed about an isosceles right triangle Circle. Write the algorithm for calculating the area of ​​a triangle and the triangle inscribed in it.

    1. #include
      #include
      using namespace std;
      float R;
      float a;
      float S;
      float r;
      float x;
      int main ()
      {
      x=sqrt (3);
      cout <> R;
      a=(R*3.0)/x;
      S=(a*a*x) /4;
      r=(a*x)/6;
      cout << "S=" << S << ";" << "r=" << r << ";" << "a=" << a << endl;
      return 0;
      }

    2. #include
      #include
      using namespace std;
      float R;
      float a;
      float S;
      float r;
      float x;
      int main ()
      {
      x=sqrt (3);
      cout <> R;
      a=(R*3.0)/x;
      S=(a*a*x) /4;
      r=(a*x)/6;
      cout << "S=" << S << ";" << "r=" << r << ";" << "a=" << a << endl;
      return 0;
      }

  2. Can someone do this?) Or at least give me a hint))
    Standard data types.
    Given an integer Y – year, lying in the range 1970–2100; integer M –
    month, lying in the range 1–12; integer D – current date, lying in
    range 1–31. Determine the number of seconds that have passed since 1 January 1970
    g. before the start of the specified date.

    1. #include

      using namespace std;

      int main ()
      {
      int YMax,YMin,D,M,S,H,Mi;
      YMin=1970;
      YMax=2100;
      M=12;
      D=31;
      H=60;
      Mi=60;
      S=60;
      S=(YMax-YMin)*M*D*H*Mi*S;
      cout<<S<<" seconds"<<endl;
      return 0;
      }

      1. Develop a library of functions to perform operations with binary
        wood. There should be a function of adding a tree node,
        removal unit, search and analysis of the need for balancing.

  3. help me please, 2 I've been sitting here racking my brain all day
    “The field of the chess board is determined by a pair of natural numbers, each of which is no more than 8: First number – vertical number (when counting from left to right), second – horizontal number (when counting from bottom to top). Given natural numbers a, b, c, d NO ​​more 8. On field a, b placed king, does it threaten field c, d.”

  4. Create a set from the number of students in your group. Display. Add students to a set of user choice and display again. The user must enter a last name to add. (The entered last name must not contain numbers or punctuation marks)
    Help to solve,I was sick on this topic.
    С

  5. Guys, please help me write a program in C++
    With a do while loop
    Calculate the sum of the terms of the series with an accuracy of E=10^-2 for a given x=0.75.
    S=7.5-lnx^3/2!+lnx^5/4!
    help me please

  6. Can anyone help me solve this problem in C++??
    In a computer game, the hero needs to go through all the halls, destroying one monster in each. Monsters have different strengths, and you can kill each of them, if the monster's strength does not exceed the hero's strength. The hero's strength increases each time by the amount of the strength of the killed monster. Known, the strength of each monster, starting hero power, and also between which halls there are doors (You can only go through the door in one direction). Define all paths, moving along which, the hero can kill all the monsters, visiting each room only once. Technical requirements: Number of halls N 10. The halls are numbered from 1 до N. File format INPUT.TXT: 1-i string – number of halls; 2-I – starting hero power; 3-i - N natural numbers separated by a space - the strength of the monsters in each room; the subsequent lines contain two natural numbers - the numbers of halls X and Y, between which there is a door from X to Y.

  7. Does anyone know,what exactly to do?))

    Develop a library of functions to perform operations with binary
    wood. There should be a function of adding a tree node,
    removal unit, search and analysis of the need for balancing

  8. I don’t know where to turn anymore, maybe you'll get lucky here…. In general, the problem does not fit in my head, please help.

    It is necessary to create a program to calculate the number of cinder blocks (laying in one row) according to the following input data: length of all walls – L, average wall height – H, total area of ​​openings (door and window) – S, approximate mortar thickness – w. Cinder block size: length l = 390 mm, height h = 188 mm. The formula for calculation is as follows:
    Q = (L * H – S)/((h+w)*(l+w)). Don't forget to coordinate units of measurement.

    ********************************************************
    * Program for calculating the number of cinder blocks *
    ********************************************************
    Length of all walls, m: _
    Average wall height, m: _
    Total area of ​​openings, sq.m: _
    Approximate thickness of solution, mm: _
    *******************************************************
    Approximate quantity of cinder blocks: pcs.
    *******************************************************

Leave a Reply

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