1-Labaratoriya ishi
N TA ELEMETNDAN TASHKIL TOPGAN MASSIV
( N–NATURAL SON)
Guruh: 070-19
Fan: Ma'lumotlar tuzilmasi va algoritmi
O'qituvchi: Shoraimov Husanboy
Talaba: Abdrimov Sanjar
Variant: 1-variant
1. Massivning manfiy min va musbat min elementlari yig’indisini toping
#include
#include
using namespace std;
int main()
{
int a[10],arr[10];
int i,min2,min1;
float summ;
srand(time(0));
cout<<"Boshlang'ich massiv : ";
for (int j=0; j<10;j++){
a[j]=rand()%20-rand()%20;
cout<min1=a[0];
cout<<"Musbat sonlardan iborat massiv : ";
for (i=0; i<10; i++){
if (min1>a[i]) min1=a[i]; }
int j=0; for (i=0; i<10; i++){
if (a[i]>=0){
arr[j]=a[i]; cout<<" "< j++;}}
cout<return 0;
}
Do'stlaringiz bilan baham: |