Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////С ЦИКЪЛ//////
- import java.util.Scanner;
- public class MAXnumber {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- System.out.print("Брой числа:");
- int n = scan.nextInt();
- System.out.println("Въведи числата:");
- int max = 0;
- for (int i=1; i<=n; i++) {
- int number = scan.nextInt();
- if (number > max){
- max = number;
- }
- }
- System.out.println("Най-голямото е:" + max);
- }
- }
- //////В МАСИВ////////
- public class masiv {
- public static void main(String[]args) {
- int[]arr = {28,3,7,20,90,99,78,65,4,10};
- int max = arr[0];
- for(int i = 1; i<=arr.length-1; i++) {
- if(max<arr[i]) {
- max=arr[i];
- }
- }
- System.out.println(max);
- }
- }
- ////////////////////
- public class Masivi {
- public static void main(String[] args) {
- int[] arr = {11,5,4,8,2,9,3,7,24};
- for (int i = 0; i < arr.length; i++) {
- for (int u = 0; u < arr.length-i; u++) {
- if (arr[i]>arr[i+u]) {
- int a = arr[i];
- arr[i] = arr[i+u];
- arr[i+u] = a;
- }
- }
- }
- System.out.print("{");
- for (int j = 0; j < arr.length; j++) {
- System.out.print(" " + arr[j] + " ");
- }
- System.out.print("}");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement