
Agallador
7 год назад
Срочно! Задача в С++ Задана последовательность N чисел. Определить, сколько среди них меньше К, равных К, больше К.
ОТВЕТЫ

Lias
Aug 13, 2019
#include lt;iostreamgt;
using namespace std;
int main() {
int N,K,L;
int gt=0,eg=0,lt=0;
coutlt;lt;"N = "; cingt;gt;N;
coutlt;lt;"K = "; cingt;gt;K;
coutlt;lt;"элементы последовательности через пробел: ";
for (int i=0; ilt;N;i++)
{ cingt;gt;L;
if (Lgt;K) gt++;
if (L==K) eg++;
if (Llt;K) lt++;
}
coutlt;lt;"меньше К: "lt;lt;ltlt;lt;endl;
coutlt;lt;"равных К: "lt;lt;eglt;lt;endl;
coutlt;lt;"больших К: "lt;lt;gtlt;lt;endl;
system("pause");
return(0);
}
using namespace std;
int main() {
int N,K,L;
int gt=0,eg=0,lt=0;
coutlt;lt;"N = "; cingt;gt;N;
coutlt;lt;"K = "; cingt;gt;K;
coutlt;lt;"элементы последовательности через пробел: ";
for (int i=0; ilt;N;i++)
{ cingt;gt;L;
if (Lgt;K) gt++;
if (L==K) eg++;
if (Llt;K) lt++;
}
coutlt;lt;"меньше К: "lt;lt;ltlt;lt;endl;
coutlt;lt;"равных К: "lt;lt;eglt;lt;endl;
coutlt;lt;"больших К: "lt;lt;gtlt;lt;endl;
system("pause");
return(0);
}
33