Скачиваний:
24
Добавлен:
15.09.2014
Размер:
2.33 Кб
Скачать
#include<stdlib.h>
#include<time.h>
#include<conio.h>
#include<stdio.h>
#include<dos.h>
#pragma inline

void sort(char *buf, int n, char *res)     //sortirovka pyzur`kom massiva
{
 int iCount, jCount;
 char var;
 for( iCount = 0; iCount < n - 1; iCount++ )
   for( jCount = iCount + 1; jCount < n; jCount++ )
     if( *( buf + iCount ) >= *( buf + jCount ))
     {
       var = *( buf + iCount );
       *( buf + iCount ) = *( buf + jCount );
       *( buf + jCount ) = var;

       var = *( res + iCount );
       *( res + iCount ) = *( res + jCount );
       *( res + jCount ) = var;
     }
}


void OutPut(char *string)
{
 unsigned int var = 160;
 //unsigned char newColor;


 label0:
 _asm{

 push 0b800h      //textoviy rejim, 1-ya stranica
 pop  es
  mov di, 1
  xor si, si
  mov cx, 19h
}

  label1:
 _asm{
  mov ax, si
  mul var
  add ax, 1
  mov di, ax
  sub di, 2
  xor bx, bx
 }

 label2:
 _asm{
  add di, 2
  xor byte ptr es:[di], 1   //blue
  jz  currect       //chtobu cvet ne bul belum, sami delaem ego green
  jmp cont
 }
 currect:
 _asm{
  mov byte ptr es:[di], 2  ///green
 }
 cont:
 _asm{
  add bx, 1
  cmp bx, 3dh  //sravneniye s koncom stranici
  jne label2
 }
 label3:
 _asm{
  add si, 1
  loop label1
 }


_asm{
 mov ah, 7  //skroll of screen
 mov al, 1   //odna stoka
 mov bh, 0
 mov ch, 0  //koordinate  lev verh
 mov cl, 0  //kolonka
 mov dh, 3dh  //prav nij
 mov dl, 3dh  //kolonka
 int 10h
 }

 exit1:
 _asm{

 mov cx, 38       //   arroy of alphas
 xor di, di
 mov si, string
 rep movsw

 }
}




int main()
{
 char buf[] = "lyoshakarpenko850502lyoshakarpenko850502";
 char res[ 38 ];
 char output[ 76 ];
 int n = 38;
 int iCount;
 int iter = 0;
 char var;
 _asm{
  mov ax, 3
  int 10h
  push 0b800h
  pop  es
 }
 gotoxy(64,2);
 printf("Enter the Matrix");



 while( 1 )
 {

  if( kbhit() )return 0;
  randomize();

 for( iCount = 0; iCount < n; iCount++ )
   res[ iCount ] = random( 100 );
   sort( res, n, buf);


 for( iCount = 0; iCount < 76; iCount += 2 )
    {
     output[ iCount ] = buf[ iCount / 2 ];
     var = random( 16 );
     !var?var++:var + 0;
     output[ iCount + 1 ] = var;
    }

  iter++;
  OutPut( output );

  delay(300);


 }

}
Соседние файлы в папке lab1sem