Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- /* 16. Exiba uma lista de 40 grupos de números sorteados de 0 a 59. Cada grupo possui 3 números que devem ser
- exibidos em ordem crescente. */
- int main()
- {
- int sorteado[3],i,j,k,aux;
- srand(time(NULL));
- for(i=0;i<40;i++)
- {
- printf("\n Grupo %d",i+1);
- for(j=0;j<3;j++)
- {
- sorteado[j]= rand() % 60;
- }
- for(j=0;j<3;j++)
- {
- for(k=0;k<2;k++)
- {
- if(sorteado[k]>sorteado[k+1])
- {
- aux=sorteado[k];
- sorteado[k]=sorteado[k+1];
- sorteado[k+1]=aux;
- }
- }
- }
- for(j=0;j<3;j++)
- {
- printf("\n %d",sorteado[j]);
- }
- printf("\n");
- }
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement