Guest User

Untitled

a guest
Dec 11th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. public static void Exerc08(int n)
  2. {
  3. String y="";
  4. String []a = new String[n];
  5. String temp="";
  6. int i;
  7. for(i=0;i<n;i++)
  8. {
  9. a[i]=IO.readString("Entre com o nome: ");
  10. for(int t=0; t<a[i].length();t++)
  11. {
  12. if (a[i].charAt(t)>='a' && a[i].charAt(t)<='z')
  13. {
  14. y +=(char)((int)(a[i].charAt(t))-32);
  15. }
  16. else
  17. {
  18. y+=a[i].charAt(t);
  19. }
  20. }
  21. a[i]=y;
  22. y="";
  23. }
  24. for(i=0;i<n-1;i++)
  25. {
  26. for(int t=0; t < a[i].length(); t++)
  27. {
  28. if(a[i].charAt(t) < a[i+1].charAt(t) )
  29. {
  30. break;
  31. }
  32. else if(a[i].charAt(t) > a[i+1].charAt(t))
  33. {
  34. temp+=a[i];
  35. a[i]=a[i+1];
  36. a[i+1]=temp;
  37. temp="";
  38. break;
  39. }
  40. }
  41. }
  42. for(i=0;i<n;i++)
  43. {
  44. IO.println(""+a[i]);
  45.  
  46. }
  47. }
  48.  
  49. public static void Exercicio08()
  50. {
  51. int n;
  52. n= IO.readint("Entre com o numero de pessoas:");
  53. Exerc08(n);
  54. }
Add Comment
Please, Sign In to add comment