Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Roman Kungurov
- // Exercise 1
- public static void main(String[] args) {
- int[] num = new int[10];
- int amount = 0;
- for(int i=0; i<10; i++) {
- if(Check(num[i]) == 1)
- amount++;
- }
- System.out.println("There are " + amount + " zehe numbers");
- }
- public static int Check(int num) {
- int i=0;
- int num1 = num;
- while(num > 0) {
- num /= 10;
- i++;
- }
- for(int j=0; j < i; j++) {
- if(!(i == num1%10))
- return 0;
- num1 /= 10;
- }
- return 1;
- }
- // Exercise 2
- public static int Reflection(int num) {
- return num*100+(num%10)*10+num/10;
- }
- // Exercise 3
- public static int[] newArr(int[] oldArr) {
- int n = oldArr.length;
- int[] newArr = new int[n];
- for(int i=0; i<n; i++) {
- int count =0;
- for(int j=i+1; j < n; j++) {
- if(oldArr[j] > oldArr[i])
- count++;
- }
- newArr[i] = count;
- }
- return newArr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement