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
It is solved more complicated there in the second cycle.
int main() { int height = 5;
// It is solved more complicated there in the second cycle 0 or 1 It is solved more complicated there in the second cycle for( int i{0}; i < height ; i ) { // It is solved more complicated there in the second cycle, It is solved more complicated there in the second cycle for ( int j{1}; j< It is solved more complicated there in the second cycle; j ) { cout << "*"; } // It is solved more complicated there in the second cycle // It is solved more complicated there in the second cycle *2+1 It is solved more complicated there in the second cycle 0 // and i*h+1 if the lines with 1 for ( int h{} ; h<and i*h+1 if the lines with ; h++) { cout << "$"; } cout << endl; } return 0; }
Isosceles triangle problem . for(int j = 1; j < height – i; j ); the compiler does not skip this line of code ,It shows an error – i; Prompt , what's the matter ?
#include
using namespace std;
void main()
{
setlocale(LC_ALL, “Rus”);
int a, crayon-6245184e679b3535057200/;
int i = 0;
double sum = 0;
cout << "Введите числа для расчета (выйти – 0)" << endl;
do
{
i ;
cout << "Число " << i <> a;
crayon-6245184e679b3535057200/;
sum += a;
} while (a != 0);
cout << "\n~~~~~~~~~~~~~~~~~~~~~~" << endl;
cout << "Кол-во введенных чисел: " << crayon-6245184e679b3535057200/ – 1 << endl;
cout << "Общая сумма: " << sum << endl;
cout << "Среднее арифметическое: " << (double)(sum / (crayon-6245184e679b3535057200/ – 1)) << endl;
}
crayon-6245184e679b3535057200/, crayon-6245184e679b3535057200/ 3 crayon-6245184e679b3535057200/)
It is solved more complicated there in the second cycle.
int main()
{
int height = 5;
// It is solved more complicated there in the second cycle 0 or 1 It is solved more complicated there in the second cycle
for( int i{0}; i < height ; i )
{
// It is solved more complicated there in the second cycle, It is solved more complicated there in the second cycle
for ( int j{1}; j< It is solved more complicated there in the second cycle; j )
{
cout << "*";
}
// It is solved more complicated there in the second cycle
// It is solved more complicated there in the second cycle *2+1 It is solved more complicated there in the second cycle 0
// and i*h+1 if the lines with 1
for ( int h{} ; h<and i*h+1 if the lines with ; h++)
{
cout << "$";
}
cout << endl;
}
return 0;
}
setlocale(LC_ALL, “rus”);
int heigt = 0;
int from = 0;
int before = 0;
cout <> sacred;
cout << endl << endl;
for ( int i = 1; i <= sacred; i )
{
from = heigt – i;
before = from + (i + i – 2);
for (int j = 0; j <= sacred – i; j )
{
cout << " ";
}
for (int j = from; j <= before; j )
{
cout << "^";
}
cout << endl;
}
return 0;
instead of cout << sacred; cin!!!
int main()
{
setlocale(LC_ALL, “rus”);
char pen = ‘^’;
int hight = 0;
int n = 0;
int d = 1;
cout <> hight;
do
{
n = 0;
while (n < hight-1)
{
cout << " ";
n++;
}
for (int i = 0; i < d; i )
{
cout << rim;
}
cout << endl;
d += 2;
hight–;
} while (hight != 0);
return 0;
}
int main() {
setlocale(LC_ALL, “rus”);
int height;
char symbol;
cout << "Эта программа рисует равнобедренный треугольник из указанных символов.\n\n"
<> symbol;
cout <> height;
cout << endl;
int spaceCounter = height;
int symbolCounter = 1;
for (int i = 1; i 0; j–) { // Space Cycle
cout << " ";
}
for (int s = 1 ; s <= symbolCounter; s ) { // Character output loop
cout << symbol;
}
symbolCounter += 2;
cout << endl;
}
return 0;
}
For some reason, when copying the code got corrupted. Corrected:
int main() {
setlocale(LC_ALL, “rus”);
int height;
char symbol;
cout << "Эта программа рисует равнобедренный треугольник из указанных символов.\n\n"
<> symbol;
cout <> height;
cout << endl;
int spaceCounter = height;
int symbolCounter = 1;
for (int i = 1; i 0; j–) { // Space Cycle
cout << " ";
}
for (int s = 1 ; s <= symbolCounter; s ) { // Character output loop
cout << symbol;
}
symbolCounter += 2;
cout << endl;
}
return 0;
}
#include
#include
#include
#include
using namespace std;
int main()
{
setlocale(LC_ALL, “Russian”);
int numb; //Variable for entering numbers
int summ=0; // Variable for summing input numbers
int rep=-1; // Variable counter input, is -1 since the last input is also taken into account
int maxnumb=0; // variable max number
int memory=1000000; // Minimum number variable
int tab[254]; // Array to store numbers
do
{
cout << endl <> numb; // Entering numbers
rep++; // Counter
if (numb !=0) tab[rep] = numb; // Entering numbers into an array
sum = sum + numb; // Sum of input numbers
if ( memory > numb && numb !=0) minnumb = numb; // Minimum number, a condition was added so that the array termination condition was not displayed
if ( maxnumb < numb ) maxnumb = numb; // Maximum number
if (numb !=0) cout << endl << " Press 0 to end." << endl;
}
while ( numb != 0 ); // array stop condition
cout << endl << " Total : " << endl;
cout << endl << " Maximum number : "<< maxnumb << endl;
cout << endl << " Minimum number : " << memory <<endl;
cout << endl << " Number of inputs : " << rep << endl;
cout << endl << " Sum of numbers : " << summ << endl;
cout << endl << " Average : " << summ / rep << endl << endl;
// Array sort loop
for (int i = 0; i tab[i+1] && tab[i+1] !=0)
{
int buff=0;
buff = tab[i] ;
tab[i] = tab [i+1];
tab[i+1] = buff;
i=-1;
}
}
cout << " Entered numbers : ";
// Array output loop
for (int i = 0 ; i<=rep-1; i ) cout <<" " << tab[i] << " ";
cout << endl<<endl;
}
int main()
{
int size;
int iterator = 0;
int symbolIterator = 0;
int var = 0;
cin >> size;
cout << "\n\n\n\n\n";
char space = ' ';
char symbol = '^';
while (iterator <= size) {
iterator++;
cout << space;
if (iterator == size) {
while (symbolIterator <= was){
cout << symbol;
symbolIterator++;}
symbolIterator = 0;
was+=2;
iterator = 0;
size–;
cout << endl;
}
}
cout << "\n\n\n\n";
Isosceles triangle problem . for(int j = 1; j < height – i; j ); the compiler does not skip this line of code ,It shows an error – i; Prompt , what's the matter ?