+ 4

Can anyone help me with my code?

https://code.sololearn.com/cU97fzpo5b2v/?ref=app I want numbers on descending order (e.g.20,19,18 ) (I will appreciate it if anyone can help me)

26th Nov 2019, 6:00 PM
Elen V
Elen V - avatar
18 Respostas
+ 2
Yes, with the help of "Ipang"( sololearn's user) Here is the thing i want to make something like this: 2019 Happy birthday! You are 20 2018 Happy birthday! You are 19 2017 Happy birthday! You are 18 .......
26th Nov 2019, 6:23 PM
Elen V
Elen V - avatar
+ 2
Subhojit Sikdar ,thank you very much 👍
28th Nov 2019, 6:15 PM
Elen V
Elen V - avatar
+ 1
MĂ©lina first of all thank you for your help. The problem is that if i make +1 to -1 my code starts from -1 and it ends to the number -1 e.g. if my number is 5 the output will be: -1 0 1 2 3 But i want 5 4 3 2 1
26th Nov 2019, 6:13 PM
Elen V
Elen V - avatar
+ 1
MĂ©linaThanks 👍 anyway because my code looks much better now (despite i am still fixing it)
26th Nov 2019, 6:28 PM
Elen V
Elen V - avatar
+ 1
MĂ©lina Wow thank you!!!!!!!!!!!!!!!!!👍👍👍👍👍👍👍👍👍👍
26th Nov 2019, 6:32 PM
Elen V
Elen V - avatar
+ 1
mport java.util.Scanner; // Compiler version JDK 11.0.2 class Dcoder { public static void main(String args[]) { int arr[] = new int [8]; Scanner sc = new Scanner(System.in); System.out.print("Enter 8 Digits (Separate with space):"); for(int i = 0; i < arr.length; i++) { arr[i] = sc.nextInt(); } int temp = 0; for(int i = 0; i < arr.length; i++) { for(int j = i + 1; j < arr.length; j++) { if (arr[i] > arr[j]) { temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } } for(int i = 0; i < arr.length; i++){ System.out.print(arr[i] + " "); } } } Guys please help me with this because I don't really understand the flow of my code. Please help
28th Nov 2019, 12:55 PM
Nerb
Nerb - avatar
+ 1
Subhojit Sikdar, first of all thank you for your help. Secondly could you please explain this to me a little more?
28th Nov 2019, 6:03 PM
Elen V
Elen V - avatar
28th Nov 2019, 5:54 PM
CoderBittu
CoderBittu - avatar
0
This is called Slicing in Python which slices a string an example ... 2 0 1 9 Has 4 digits We have to consider this as a string then number it 2 0 1 9 0 1 2 3 Then printing str[2:1000] It will start printing char starting from 2 which means 1 and I set the stopping number to 1000 because I think it's undefined and printing the string will end after 1000 characters as defined .. formula: string[startnumber : endnumber] Suppose I am subhojit slice it and display subho only str="subhojit" Print(str[0:4])
28th Nov 2019, 6:09 PM
CoderBittu
CoderBittu - avatar
0
Glad I could help! 😉
28th Nov 2019, 6:20 PM
CoderBittu
CoderBittu - avatar