Advertisement
Guest User

Untitled

a guest
May 19th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4. #include<conio.h>
  5.  
  6. int main() {
  7. int x,a=0,cont,cont1,cont2,cont3,cont4,cont5,cont6,cont7,cont8,cont9,cont10,cont11,y,c=0,d=1001,e=0,z=0,n=0,num=0,nu=0,pi=0,k=0,pitoca=0;
  8. char string[1000][10],matriz[20];
  9. int vetor[1000],substituto[12],vetor2[1000],vetor3[1000];
  10.  
  11. while(1){
  12. pitoca=pitoca+1;
  13. e=0;
  14. scanf("%d",&x);
  15. if(x==0){break;}
  16.  
  17. for(cont=1;cont<=x;cont++){
  18. scanf("%s",string[cont]);
  19. d=1001;
  20. c=0;
  21. for(cont1=1;cont1<=12;cont1++){
  22. scanf("%d",&y);
  23. substituto[cont1]=y;
  24. if(d>y){d=y;}//d=menor.
  25. if(c<y){c=y;}//c=menor.
  26. }
  27. vetor[cont]=0;
  28. for(cont2=1;cont2<=12;cont2++){
  29. vetor[cont]=vetor[cont]+substituto[cont2];}
  30. vetor[cont]=vetor[cont]-d-c;
  31. }//já se tem todos os nomes e pontuações!
  32. e=x;
  33. for(cont3=1;cont3<=x;cont3++){
  34. for(cont4=1;cont4<e;cont4++){
  35. if(vetor[cont4]>vetor[cont4+1]){
  36. z=vetor[cont4+1];
  37. strcpy(matriz,string[cont4+1]);
  38. vetor[cont4+1]=vetor[cont4];
  39. strcpy(string[cont4+1],string[cont4]);
  40. vetor[cont4]=z;
  41. strcpy(string[cont4],matriz);}//fecha if
  42. }e=e-1;}//agora já temos todas as pontuações da menor para maior,com os nomes respectivos
  43. num=0;
  44. for(cont5=1;cont5<=x;cont5++){
  45. vetor2[cont5]=0;}
  46. for(cont6=1;cont6<=x;cont6++){
  47. vetor2[vetor[cont6]]=vetor2[vetor[cont6]]+1;}
  48. for(cont7=1;cont7<=1000;cont7++){
  49. if(vetor2[cont7]!=0){
  50. num=num+1;
  51. vetor3[num]=vetor[cont7];}}//fecha for
  52. nu=0;
  53. pi=0;
  54. for(cont8=1;cont8<=num;cont8++){
  55. nu=nu+1;
  56. pi=vetor3[nu];
  57. for(cont9=1;cont9<vetor3[nu];cont9++){
  58. for(cont10=1;cont10<pi;cont10++){
  59. k=strcmp(string[cont10],string[cont10+1]);
  60. if(k<0){
  61. strcpy(matriz,string[cont10+1]);
  62. strcpy(string[cont10+1],string[cont10]);
  63. strcpy(string[cont10],matriz);}}
  64. pi=pi-1;}
  65. }
  66. printf("Teste %d\n");
  67. for(cont11=1;cont11<=x;cont11++){
  68. printf("%s %d\n\n",string[cont11],vetor[cont11]);}
  69.  
  70. }
  71.  
  72.  
  73.  
  74.  
  75.  
  76. system("pause");
  77. return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement