fork download
  1.  
  2. #include <stdlib.h>
  3. #include<stdio.h>
  4. #include<math.h>
  5.  
  6. /// Bianca Valéria Lopes Pereira
  7. //// Lista 2 - eda - 3 questão
  8.  
  9.  
  10. int radixd(int *vetor, int n, int vx){
  11.  
  12. int i, matriz[n][vx],k,aux,j;
  13. for (i=0;i<n;i++){
  14. for (k=0;k<vx;k++){
  15. while (k==0){
  16. int calNP = vetor[i]%10;
  17. matriz[i][k]=calNP;
  18. }
  19. while(k!=0){
  20. int calNP = (vetor[i]/(10*k));
  21. while(calNP>9) calNP = calNP%10;
  22. matriz[i][k]=calNP;
  23. }
  24. }
  25. }
  26. for(i=0; i<n; i++) vetor[i]=0;
  27.  
  28. for (i=0;i<n;i++){
  29. int aux;
  30. for(k=(vx-1);k>=0;k--){
  31. aux = matriz[i][k];
  32.  
  33. for(j=(k-1);j>=0;j--){
  34. if(aux<matriz[i][j]){
  35. matriz[i][k]=matriz[i][j];
  36. matriz[i][j]=aux;
  37. aux=matriz[i][k];
  38. }
  39. }
  40. }
  41. }
  42.  
  43. for(i=0;i<n;i++){
  44. int exp=0;
  45. for(k=vx-1;k>=0;k++){
  46. int potencia= pow(10,exp);
  47. vetor[i]= vetor[i]+ matriz[i][k]*potencia;
  48. exp++;
  49. }
  50. }
  51.  
  52. return *vetor;
  53. }
  54.  
  55.  
  56. int main() {
  57.  
  58. int n;
  59. scanf("%d", &n);
  60.  
  61. while(n == 0){
  62. exit(0);
  63. }
  64. while (n>50) {
  65. exit(0);
  66. }
  67.  
  68. int vetor[n], i, maiorNumero;
  69.  
  70. for(i=0;i<n;i++){
  71. scanf("%d", &vetor[i]);
  72. if (vetor[i]>100000) exit(0);
  73. if(vetor[i]<=vetor[i+1]) maiorNumero = vetor[i+1];
  74. if(vetor[i]>vetor[i+1]) maiorNumero = vetor[i];
  75. }
  76.  
  77. int vx;
  78. if((maiorNumero/10) == 0) vx=1;
  79. if((maiorNumero/100) == 0) vx=2;
  80. if((maiorNumero/1000) == 0) vx=3;
  81. if((maiorNumero/10000) == 0) vx=4;
  82. if((maiorNumero/100000) == 0) vx=5;
  83.  
  84. radixd(vetor, n , vx);
  85.  
  86. for(i=0;i<n;i++){
  87. if(vetor[i]<=vetor[i+1]) maiorNumero = vetor[i+1];
  88. if(vetor[i]>vetor[i+1]) maiorNumero = vetor[i];
  89. }
  90. printf("%d \n", maiorNumero);
  91.  
  92. main();
  93. }
  94.  
  95.  
Success #stdin #stdout 0s 15224KB
stdin
Standard input is empty
stdout
Standard output is empty