domingo, 3 de fevereiro de 2013

Gerando números aleatórios em matriz II


#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <conio2.h>
int main(){
system ("title GERANDO NUMEROS ALEATORIOS EM MATRIZ");
srand ( time ( NULL ) );
int a [11] [11] , n, m, i, j, ord = 0, aux;
system("cls");
textcolor(LIGHTRED);gotoxy(25,3);printf("GERANDO NUMEROS ALEATORIOS EM MATRIZ"); // Código Pronto
textcolor(YELLOW);gotoxy(24,5);printf("Programa desenvolvido por:");
textcolor(LIGHTCYAN);gotoxy(52,5);printf("Samuel Lima");
textcolor(LIGHTBLUE);gotoxy(35,7);printf("sa_sp10@hotmail.com");
textcolor(WHITE);gotoxy(30,9);printf("DIGITE O NUMEROS DE LINHAS:  ");
textcolor(LIGHTRED);scanf ( "%d",&n );fflush (stdin);
textcolor(WHITE);gotoxy(30,11);printf("DIGITE O NUMERO DE COLUNAS:  ");
textcolor(LIGHTRED);scanf ( "%d",&m );fflush (stdin);
system("cls");
textcolor(LIGHTRED);gotoxy(25,3);printf("GERANDO NUMEROS ALEATORIOS EM MATRIZ");
textcolor(LIGHTBLUE); gotoxy(36,5);printf("GERANDO A MATRIZ...");
gotoxy(20,6);textcolor(YELLOW);
for ( i = 0; i <= n; i++ ){
printf("\n\t\t");
for ( j = 0; j <= m; j++ ){
a [i] [j] = rand () % 10; Sleep(50);
printf(" %3d ", a [i] [j]);
}
printf("\n");
}
textcolor(LIGHTRED);gotoxy(25,3);printf("GERANDO NUMEROS ALEATORIOS EM MATRIZ");
textcolor(LIGHTBLUE); gotoxy(36,5);printf("MATRIZ  BEM  GERADA");
textcolor(LIGHTGRAY);gotoxy(32,23);printf("PRESSIONE QUALQUER TECLA");
getche();
system("cls");
textcolor(LIGHTRED);gotoxy(25,3);printf("GERANDO NUMEROS ALEATORIOS EM MATRIZ");
textcolor(LIGHTBLUE);gotoxy(22,5);printf("MOSTRANDO OS NUMEROS GERADOS DESORDENADOS");
textcolor(YELLOW);printf("\n");
for ( i = 0; i <= n ; i++ ){
printf("\n\t\t");
for ( j = 0; j <= m ; j++ ){
printf(" %3d ", a [i] [j]);
}
printf("\n");
}
getche();
system("cls");
textcolor(LIGHTRED);gotoxy(25,3);printf("GERANDO NUMEROS ALEATORIOS EM MATRIZ");
textcolor(LIGHTBLUE);gotoxy(22,5);printf("MOSTRANDO OS NUMEROS ORDENADOS POR COLUNAS ");
while(ord == 0){
ord = 1;
for ( i = 0; i <= n; i++ ){
for(j = 0; j <= m ; j++){
if( a  [i] [j]  > a [(i + 1)] [j]){
aux = a [i] [j];
a [i] [j] = a [(i + 1)] [j];
a [(i + 1 )] [j] = aux;
ord = 0;
}
}
}
}
gotoxy(20,7);textcolor(YELLOW);
for ( i = 0; i <= n; i++ ){
printf("\n\t\t");
for ( j = 0; j <= m; j++ ){
printf(" %3d ", a [i] [j]);
}
printf("\n");
}
textcolor(LIGHTRED);gotoxy(35,23);printf("\aO ROCCO AGRADECE");
getche();
}

Nenhum comentário:

Postar um comentário

Observação: somente um membro deste blog pode postar um comentário.