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
In the first task I wrote differently, this is not a mistake? #include using namespace std;
int main() { setlocale(LC_ALL, “”); int a = 0; int b; int g = 0; start : cout <> b; for (; b != 0;) { a++; g += b; goto start; } if (a < 5) { cout << "Ви ввели " << a << " number" << endl; } else { cout << "Ви ввели " << a << " numbers" << endl; } cout << "Сумма усіх чисел: " << g << endl; cout << "Середнє арифметичне усіх чисел: " << g / a << endl;
Hello ! Most requested ! Give a detailed description of the solution to the problem of constructing a filled triangle from symbols ! If it exists at all . because I can’t find it on the internet ! Thank you in advance , who will respond. Of course , I have my own version , however, I would like to see the specialist’s description.
3-egg task using while int main() { setlocale(LC_ALL, “RU”); int high; int checker = 0; string three = “^”; string tr = “^^”; int i = 1; int counter; cout << "Введите высоту равнобедренного треугольника: " <> high; counter = high; while (checker < high) { for (i; i <= high;i ) { cout << " "; } cout << Three <<endl; tre += tr; checker++; counter–; i -= counter ; } }
#include
using namespace std;
int main()
{
setlocale(LC_ALL, “rus”);
double min_digit = 0;
double max_digit = 0;
double sum_digit = 0;
cout <> min_digit;
cout <> max_digit;
for (int i = min_digit; i <= max_digit; i )
{
if (i % 2 == 0)
{
continue;
}
cout << i << " " ;
sum_digit += i;
}
cout << endl;
cout << "Сумма нечетных чисел в диапазоне от " << min_digit << " to " << max_digit << " = " << sum_digit << endl;
return 0;
}
In the first task I wrote differently, this is not a mistake? #include
using namespace std;
int main() {
setlocale(LC_ALL, “”);
int a = 0;
int b;
int g = 0;
start : cout <> b;
for (; b != 0;) {
a++;
g += b;
goto start;
}
if (a < 5) {
cout << "Ви ввели " << a << " number" << endl;
}
else {
cout << "Ви ввели " << a << " numbers" << endl;
}
cout << "Сумма усіх чисел: " << g << endl;
cout << "Середнє арифметичне усіх чисел: " << g / a << endl;
}
Hello ! Most requested ! Give a detailed description of the solution to the problem of constructing a filled triangle from symbols ! If it exists at all . because I can’t find it on the internet ! Thank you in advance , who will respond. Of course , I have my own version , however, I would like to see the specialist’s description.
#include
using namespace std;
int main()
{
setlocale(LC_ALL, “rus”);
int a = 0;
cout <> a;
for (int i = 0; i <= a; i ) {
for (int j = 0; j = a – i && j <= a + i) cout << "^";
else cout << " ";
}
cout << "\n";
}
return 0;
}
3-egg task using while
int main() {
setlocale(LC_ALL, “RU”);
int high;
int checker = 0;
string three = “^”;
string tr = “^^”;
int i = 1;
int counter;
cout << "Введите высоту равнобедренного треугольника: " <> high;
counter = high;
while (checker < high) {
for (i; i <= high;i ) {
cout << " ";
}
cout << Three <<endl;
tre += tr;
checker++;
counter–;
i -= counter ;
}
}
1 The task:
#include “iostream”
using namespace std;
int main()
{
setlocale(LC_ALL, “Russian”);
int sum = 0, avr, dig, kol = 0, SIZE=0;
for (int j = 0; ; j ) {
cin >> dig;
sum += dig;
if (dig == 0) break;
kol++;
}
cout << "Количество элементов: " << crayon-6245184e679b3535057200/ << endl;
cout << "Сумма: " << sum << endl;
cout << "Ср. арефм.: " << (sum / crayon-6245184e679b3535057200/) << endl;
return 0;
}