[Solved] Write a programme to input 10 numbers from the user and print greatest of all

If you have an array declared like int a[N]; where N is some positive integer value then the valid range of indices to access elements of the array is [0, N). It means that for example this for loop for(i=1;i<=10;i++) { printf(“enter 10 nos. for arr[%d] :”,i); scanf(“%d”,&arr[i]); } must look like for ( i … Read more

[Solved] select id by the min and max (sql) [closed]

You can use the MAX() and MIN() function to get the ids having largest and the id having smallest discount. Select id,discount from customer where discount=(select MAX(discount) from customer) OR discount=(select MIN(discount) from customer); 3 solved select id by the min and max (sql) [closed]

[Solved] Does C++ standardize the behavior of std::optional under std::min and std::max?

Is something like what I expected standardized in C++17 No. , or proposed for standardization later? There is no such proposal in any of the mailings. Though of course there’s plenty of easy workarounds, so there’s little reason for such a proposal: oy ? std::max(x,*oy) : x; x < oy ? *oy : x *std::max(oint(x), … Read more

[Solved] What does this `key=func` part mean in `max(a,b,c,key=func)` in Python?

it allows to define a criterion which replaces the < comparison between elements. For instance: >>>l = [“hhfhfhh”,”xx”,”123455676883″] >>>max(l, key=len) ‘123455676883’ returns the longest string in the list which is “123455676883” Without it, it would return “xx” because it’s the highest ranking string according to string comparison. >>>l = [“hhfhfhh”,”xx”,”123455676883″] >>>max(l) ‘xx’ 2 solved What … Read more

[Solved] Python miminum length/max value in dictionary of lists

def get_smallest_length(x): return [k for k in x.keys() if len(x.get(k))==min([len(n) for n in x.values()])] def get_largest_sum(x): return [k for k in x.keys() if sum(x.get(k))==max([sum(n) for n in x.values()])] x = {‘a’: [4, 2], ‘c’: [4, 3], ‘b’: [3, 4], ‘e’: [4], ‘d’: [4, 3], ‘g’: [4], ‘f’: [4]} print get_smallest_length(x) print get_largest_sum(x) Returns: [‘e’, ‘g’, … Read more

[Solved] How to get second MAXIMUM DATE in MYSQL

It wasn’t fun to read your query, but I think the problem is here: LEFT JOIN ( SELECT max(notification_date) notification_date, client_id FROM og_ratings WHERE notification_date NOT IN ( SELECT max(notification_date) FROM og_ratings ) if you want the maximum date for every client you need to GROUP BY client_id: SELECT client_id, max(notification_date) notification_date FROM og_ratings GROUP … Read more

[Solved] max() function gives wrong output [closed]

Because you are comparing character strings. Consider… max(“apple”,”banana”,”banana2″) #[1] “banana2” max( “1” , “2” , “10” ) #[1] “2” sort( c( “1” , “2” , “10” ) ) #[1] “1” “10” “2” sort( as.integer( c(“1” , “2” , “10” ) ) ) #[1] 1 2 10 max( as.integer( c(“1” , “2” , “10” ) ) … Read more

[Solved] What does “const int&” do as a return type?

In general, returning a reference avoids that the return value gets copied, and (if it is not const-qualified) gives you the opportunity to change the “original” value. A return type const T& is often used in conjunction with objects of class type, e.g. std::vector, where copying could result in (unwanted) overhead. In conjunction with elementary … Read more

[Solved] mysql , max ,groub by [closed]

suggest that if your above SQL statement can query the result. maybe you can just skip the “order by” and simply just select * from (/* your SQL statement without “order by”*/) a order by a.message_id desc sorry that as it is difficult to see your screen capture and help you to resolve the SQL … Read more

[Solved] mySQL Largest number by group

In general ORDER BY in a sub-query makes no sense. (It only does when combined with FETCH FIRST/LIMIT/TOP etc.) The solution is to use a correlated sub-query to find the heaviest fish for the “main query”‘s current row’s username, location, species combination. If it’s a tie, both rows will be returned. SELECT * FROM entries … Read more

[Solved] JOIN ON WITH MAX VALUE MYSQL

If you just want the max score per student you can aggregate the rows before joining: select s.id_student, u.name, u.role, s.status, u.no_phone, s.exam_status, sc.score from student s join user u on u.username = s.id_student join ( select Max(score) as score, id_student from score group id_student )sc on sc.id_student = s.id_student where mod(s.id_student, 2) = 0 … Read more

[Solved] C++ std::max acting like std::min

The error is that you are re-using the teleportation_start_position variable. teleportation_start_position = min(teleportation_start_position, teleportation_end_position); Before this line the state of your program is: teleportation_start_position = 8 teleportation_end_position = 2 But after, it is: teleportation_start_position = 2 teleportation_end_position = 2 So in the next line you are doing: teleportation_end_position = max(teleportation_start_position, teleportation_end_position); // teleportation_end_position = max(2, … Read more