СЩ
Сергей Щеглов
Дан двумерный массив. Найти положит. и отрицат. чисел и количество нулей
На любом
На любом
arr.each do |v| if (v > 0) then cp++; else if (v < 0) cm++; else c0++; end;
а какой язык программирования?
такое есть в интернете, если хорошенько поискать
На C++:
#include
using namespace std;
int main(){
int m,n,np=0,nm=0,nz=0,a[ 40][ 40]; cout<<"m n? "; cin>>m>>n;
for(int i=0;i< m;i++){cout<<"Enter "<< n<<" numbers of the line "<< i+1<< endl;
for(int j=0;j< n;j++)cin>> a[ i][ j];}
for(int i=0;i< m;i++)for(int j=0;j< n;j++)
{np+=a[ i][ j]> 0; nm+=a[ i][ j]< 0; nz+=a[ i][ j]== 0;}
cout<<"+: "<< np<<" , -: "<< nm<<" , 0: "<< nz<< endl; cin.get(); cin.get();}