Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <conio.h>
- #include <dos.h>
- #include <stdlib.h>
- #include <windows.h>
- #include <time.h>
- #include <ctype.h>
- #include <locale.h>
- #include <math.h>
- void cores(int ForgC, int BackC){ // para chamar
- WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);;
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), wColor);
- return;
- }
- void textcolor(int newcolor){
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
- (csbi.wAttributes & 0xf0) | newcolor);
- }
- void gotoxy(int x, int y) {
- COORD c;
- c.X = x - 1;
- c.Y = y - 1;
- SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c);
- }
- void imp_autor(){
- setlocale(LC_ALL, "Portuguese");
- gotoxy(27,12);
- textcolor(10);
- printf("Fernando Henrique Arnhold");
- Sleep(250);
- system("cls");
- textcolor(15);
- }
- //GLOBAL
- struct pessoas{
- char nome[20];
- int proximo;
- };
- struct pessoas pes[10];
- int anterior;
- int primeiro;
- //FUNCTIONS
- void preenche(){
- strcpy(pes[0].nome, "BILL GATES");
- strcpy(pes[1].nome, "PAUL ALLEN");
- strcpy(pes[2].nome, "STEVE BALLMER");
- strcpy(pes[3].nome, "CLIVE SINCLAIR");
- strcpy(pes[4].nome, "PETER CHEN");
- strcpy(pes[5].nome, "STEVE WOZNIAK");
- strcpy(pes[6].nome, "JEAN PAUL JACOB");
- strcpy(pes[7].nome, "STEVE JOBS");
- strcpy(pes[8].nome, "ADA LOVELACE");
- strcpy(pes[9].nome, "BLAISE PASCAL");
- int i;
- for(i = 0; i < 10; i++){
- pes[i].proximo = -2;
- }
- }
- void firstPeople(){
- primeiro = anterior = rand()%10;
- }
- // -------------- AQUI COMEÇA NOSSO PROGRAMA PROPRIAMENTE DITO -----------------
- main()
- {
- int posAtual, cont=0;
- int proximo;
- imp_autor();
- srand(time(NULL));
- preenche();
- firstPeople();
- while(cont < 9 ){
- posAtual = rand()%10;
- while(pes[posAtual].proximo == -2 && posAtual != anterior){
- pes[anterior].proximo = posAtual;
- anterior = posAtual;
- cont++;
- }
- }
- int i=1;
- printf("\n ***FILA SORTEADA***\n");
- printf("\n%4dº %4s", i, pes[primeiro].nome);
- proximo = pes[primeiro].proximo;
- for(i=1;i<10;i++){
- printf("\n%4dº %4s %4d",i+1, pes[proximo].nome, pes[proximo].proximo);
- proximo = pes[proximo].proximo;
- }
- getch(); // força uma parada do programa no final da seua execução.
- }
Advertisement
Add Comment
Please, Sign In to add comment