Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2015
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. int main(){
  6. char nome[21], reprovado[21];
  7. int nota, notareprovado;
  8. int qt, i = 1;;
  9. while (scanf ("%d", &qt) != EOF) {
  10. printf("Instancia %d\n", i);
  11. i++;
  12. scanf("%s %d", reprovado, &notareprovado);
  13. int aux;
  14. for(aux = 2; aux <= qt; aux++){
  15. scanf("%s %d", nome, &nota);
  16. if (nota < notareprovado){
  17. notareprovado = nota;
  18. strcpy(reprovado, nome);
  19. } else if (nota == notareprovado){
  20. notareprovado = nota;
  21. int t;
  22. for (t = 0; t < strlen(nome); t++){
  23. if (nome[t] == reprovado[t]) {
  24. continue;
  25. } else if (nome[t] > reprovado[t]) {
  26. strcpy(reprovado, nome);
  27. break;
  28. } else {
  29. break;
  30. }
  31. }
  32. }
  33.  
  34. }
  35. printf("%s", reprovado);
  36. printf("\n");
  37. memset( reprovado, '\0', sizeof(reprovado) );
  38. nota = 0;
  39. }
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement