The basics of programming in c++ for beginners

Tasks: C++ Functions

Continuing to acquaint you withфункциями в C offerindependently  several tasks. Расположены они по уровню сложности.

1. Объявить два целочисленных array  with different sizes and write function, that fills their elements and values ​​shown on the screen. Функция должна принимать два параметра – массив и его размер.

2. Необходимо создать двумерный массив 5 х 5. Далее написать функцию, which fills its random numbers from 30 to 60. Создать еще две функции, которые находят максимальный и минимальный элементы этого двумерного массива. (ABOUTгенерации случайных чисел a separate article)

3. Написать игру в которой имитируется бросание кубиков компьютером и пользователем. В игре 2 dice and each of them may fall from 1 to 6 очков. Реализовать определение программой первого ходящего. Каждый делает по четыре броска.  After the shots show, нарисованные символами кубики и количество очков, выпавших на них. After a couple of shots (бросок компьютера + бросок пользователя) display the intermediate result– the number of the player and the computer score.  After announce, who won on the basis of all the shots.

39 thoughts on “Tasks: C++ Functions

  1. Solution third problem I got so

    1. NO ONE! will read your sheets, placed in a comment.
      ALL: Do not write your code in a comment – Comments are not for!

      1. AND FOR SOMETHING HE HAS TWO MORE LEFT ANGLE BRACKETS THAN RIGHT ANGLE BRACKETS!!!!!

  2. I have a question about the third task:
    When drawing die with ascii using setlocale (LC_ALL, “rus”), some characters are replaced by letters of the Russian alphabet. If you remove the setlocale (LC_ALL, “rus”), everything becomes normal…. Only if the program disappears Russian font. Who faced with this problem?

  3. AChRs * net, How can you solve the third problem? Why are the other light, and the third though experts?

  4. The third task is given for this purpose, to sit quietly, try to figure out what's what. After reading the comments several times and looking calmly and thoughtfully at the code itself, many things become clear. You don't have to solve this problem yourself. Try to write below by copying and understanding it little by little! It will be very useful!

  5. //dz 1. Declare two integer arrays with different
    //sizes and write a function, that fills their elements and values ​​shown on the screen. The function should take two
    //parameter – array and its size.
    int massivfunk(int arr[], int arr1[], const int SIZE1, const int SIZE2)
    {
    for (int i = 0; i < SIZE1; i )
    {
    arr[i] = i + 1;

    }
    for (int j = 0; j < SIZE2; j )
    {
    arr1[j] = j + 1;
    }
    return 0;
    }
    int Vivodim(int arr[], int arr1[], const int SIZE1, const int SIZE2)
    {
    for (int i = 0; i < SIZE1; i )
    {

    cout << arr[i] << endl;
    }
    cout << endl;
    for (int j = 0; j < SIZE2; j )
    {

    cout << arr1[j] << endl;
    }
    return 0;
    }
    int main()
    {
    const int SIZE1 = 30;
    const int SIZE2 = 20;
    int arr[SIZE1] = {};
    int arr1[SIZE2] = {};
    arr[SIZE1] = solid radio(arr, arr1, SIZE1, SIZE2);
    arr1[SIZE2] = solid radio(arr, arr1, SIZE1, SIZE2);
    Vivodim(arr, arr1, SIZE1, SIZE2);
    }
    P.S in your solution the conditions are not met- that the function fills array elements with values. It fills me up.

Leave a Reply

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