KHỞI TẠO MẢNG 2 CHIỀU TĂNG DẦN VÀ GIẢM DẦN

Mảng Tăng:
   void nhap(int a[][max],int d,int c)
         {
                srand((unsigned) time(NULL));
                int t=abs(rand()%100);
                for(int i=0;i<d;i++)
                      for(int j=0;i<c;j++)
                         {
                           a[i][j]=t+abs(rand()%100);
                            t= a[i][j];
                            }
              }

Mảng Giảm:
   void nhap(int a[][max],int d,int c)
         {
                srand((unsigned) time(NULL));
                int t=abs(rand()%100);
                for(int i=d-1;i>=0;i--)
                      for(int j=c-1;i>=0;j--)
                         {
                           a[i][j]=t+abs(rand()%100);
                            t= a[i][j];
                            }
              }

Share this

Related Posts

Previous
Next Post »