+ 4
I want a algorithm for finding the ranks of the numbers
if I have taken 5 numbers 20 10 30 20 50 then the output should be 20. 3 10. 4 30. 2 20. 3 50. 1 this is the problem plz help
21 Respostas
+ 8
int array[10];
for(int i=0;i<10 ;i++){
cin>>0array[i];
}
for(int x=10;x>=0;x--){
cout<<x<<". "<<array[x]
}
return 0
+ 8
OK i didn' t understand the question.
dammat i didn" t read correctly.
you can just put an if in the for
+ 8
i LL say you what does it take.
I am busy until 18.00
+ 8
ah lol just put a new array to compare and an if at the end
+ 7
ooh come on this is not so hard
+ 7
it is way easier
https://code.sololearn.com/c2FyHF7at2Yc/?ref=app
edit: nope i m wrong i will correct it later
+ 6
https://code.sololearn.com/c04T3J2R5J0s/?ref=app
It is a good training.
Thanks for the inspiration :D
+ 4
You can use any of the sorting problems like insertion sort,merge sort, bubble sort, heap sort....
And for each time in the loop print the value of the loop counter(gives you the index). Start the for loop from n( size of the input array) and then decrement it till it becomes negative.
That's it Bro. cool..
+ 4
If the values are same then their ranks will be same.
+ 4
right one manish
+ 3
@umbe You are not at all sorting them. You are just printing the numbers in the reverse order....
+ 3
it's ok, this one is a really tough problem @umbe
+ 3
This is not that hard as of moving mount everest.
+ 2
bro it does not work if there are same number present, like 20 & 20 in given example the output by your method is
20. 3
10. _5
30. 2
20. 3
50. 1
+ 2
ya but the ranks after the same rank is not correct
+ 2
@umbe is that some kind of joke 😂😂😂😂😂😂
+ 2
try it bro you will understand @umbe
+ 2
ya I said it is tough not impossible
and on the second hand it is a very exciting problem you get to learn a lot
+ 2
ok @umbe
+ 1
no bro @umbe the sequence of number should not be changed and there is no same rank for 2 same numbers. still nice try 🤗🤘