Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. class b1{
  2. public static void reverseDigits(long number) {
  3. if (number < 10) {
  4. System.out.print(number+" ");
  5. return;
  6. }
  7. else {
  8. System.out.print(number % 10+" ");
  9. reverseDigits(number/10);
  10. }
  11. }
  12. public static void main(String[] args) {
  13. reverseDigits(98198187);
  14. }
  15. }
  16.  
  17. import java.util.Arrays;
  18.  
  19. public class b2 {
  20.  
  21. static void bubbleSort(int arr[], int n) {
  22.  
  23. if (n == 1)
  24. return;
  25. for (int i=0; i<n-1; i++)
  26. if (arr[i] > arr[i+1])
  27. {
  28.  
  29. int temp = arr[i];
  30. arr[i] = arr[i+1];
  31. arr[i+1] = temp;
  32. }
  33.  
  34. bubbleSort(arr, n-1);
  35. }
  36.  
  37. public static void main(String[] args)
  38. {
  39. int arr[] = {64, 34, 25, 12, 22, 11, 90};
  40. bubbleSort(arr, arr.length);
  41. System.out.println("Max : ");
  42. System.out.println((arr[arr.length-1]));
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement