1. Organize continuous input of numbers with the keyboard, until the user has entered 0. After entering a zero, show on the screen the number of numbers, which were introduced, their total amount and the arithmetic mean. Tip: you must declare the counter variable, that will count the number of entered numbers, and variable, that will accumulate a total sum of numbers.
View code
задача do while c++
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
usingnamespacestd;
intmain()
{
setlocale(LC_ALL,"rus");
intamountDigits=0;// количество введенных чисел
doubletotalSum=0;// общая сумма
doubledigit=0;//
cout<<"Введите числа, для расчета (выйти - 0)\n\n";
do
{
cout<<"Число "<<amountDigits+1<<" = ";
cin>>digit;
if(digit)// если digit любое значение кроме 0(false)
{
amountDigits++;
totalSum+=digit;
}
}while(digit);// пока digit любое значение отличное от 0
Oh-a-lol . for the final solution of the problem it was not easy to understand , much less write. I had to brush up on something he did not know. I believe it is necessary in parallel with the programming should be studied as a subject of Logic. And know well the math. I continue to gnaw science.
You task in an error in the code ____ for(int b=height-2*a; b++)) ____ should be so ______ for(int b;b=height-2*a; b++)________ if it gives your initialization error
The example is written: for (int j = height - 2 * i; j <= height; j++)
And this correctly! And the fact that you have written, – this is bullshit: here you have declared not initialized cycle variable b, with undetermined,any (trash!) initial cycle value.
sorry I forgot to write what task error, in the problem of the pyramid. Although I do not know how other compilers can react to it,I have a hard CODE BLOCKS VISUAL STUDIO and at the second I do not use so far although it is much better
I can not see the code problem
By clicking on the button nothing happens
Try a different browser
Do not write your code in a comment.
He does not want here!
Prompt,you are welcome, where is the mistake, I can not understand what's wrong done, displays the result just 0
I found his herd, I do not know how to remove a comment here)
size
Oh-a-lol . for the final solution of the problem it was not easy to understand , much less write.
I had to brush up on something he did not know. I believe it is necessary in parallel with the programming should be studied as a subject of Logic. And know well the math.
I continue to gnaw science.
You task in an error in the code ____ for(int b=height-2*a; b++)) ____ should be so ______ for(int b;b=height-2*a; b++)________ if it gives your initialization error
The example is written:
for (int j = height - 2 * i; j <= height; j++)
And this correctly!
And the fact that you have written, – this is bullshit: here you have declared not initialized cycle variable b, with undetermined,any (trash!) initial cycle value.
sorry I forgot to write what task error, in the problem of the pyramid. Although I do not know how other compilers can react to it,I have a hard CODE BLOCKS VISUAL STUDIO and at the second I do not use so far although it is much better
S=Ln(10+Ln(9+Ln(8+…+Ln(2+Ln(1))…))).