Guest User

Untitled

a guest
Apr 26th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import acm.program.*;
  2. public class set2ask1 extends Program {
  3. public void run() {
  4. int n = readInt("Dwse ari8mo polewn: ");
  5. double [] pa = new double [n];
  6. String [] pb = new String [n];
  7. for(int i=0; i<n; i++){
  8. pa[i] = readDouble("Dwse 8ermokrasia polhs: ");
  9. pb[i] = readLine("Dwse onoma polhs: ");
  10. }
  11. double mesh, syn;
  12. syn=0;
  13. for(int i=0; i<n; i++){
  14. syn= syn+pa[i];
  15. }
  16. mesh= syn/n;
  17. println("H mesh 8ermokrasia einai, "+mesh);
  18. void bubblesort(int[]pa; int[]pb);
  19. void bubblesort(int[]pa; int[]pb){
  20. boolean e;
  21. do{
  22. e=false;
  23. for(int i=0; i<pa.lneght-1; i++){
  24. if(pa[1]>pa[i+1]){
  25. swap(pa,i,i+1);
  26. swap(pb,i,i+1);
  27. e=true;
  28. else if( pa[i]=pa[i+1]){
  29. if(pb[1]>pb[i+1]){
  30. swap(pb,i,i+1);
  31. swap(pa,i,i+1);
  32. e=true;
  33. }
  34. }
  35. }
  36. }
  37. }while(e);
  38. }
  39. for(int i=0; i<n; i++){
  40. println (pa[i]+pb[i]);
  41. }
  42. }
  43. }
Add Comment
Please, Sign In to add comment