массив
Добавлено: 24 ноя 2007, 11:15
#include < iostream >
#include < stdlib.h >
#include < time.h >
using namespace std;
void main()
{
const int n = 10;
int a[n];
for(int i = 0; i < n; i++)
{
cout << "Input the a[" << i << "] element:\t";
cin >> a;
}
int count = 0;
for(i = 0; i < n; i++) // объясните кусок этого кода как выполняется поиск отрицательных илементов
if(a < 0)
count++; // (Подсчет как эта строка считает)
cout << endl;
for(i = 0; i < n; i++)
cout << a << "\t";
cout << "\nNumber of negative elements:\t" << count << endl;
}
#include < stdlib.h >
#include < time.h >
using namespace std;
void main()
{
const int n = 10;
int a[n];
for(int i = 0; i < n; i++)
{
cout << "Input the a[" << i << "] element:\t";
cin >> a;
}
int count = 0;
for(i = 0; i < n; i++) // объясните кусок этого кода как выполняется поиск отрицательных илементов
if(a < 0)
count++; // (Подсчет как эта строка считает)
cout << endl;
for(i = 0; i < n; i++)
cout << a << "\t";
cout << "\nNumber of negative elements:\t" << count << endl;
}