1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Jun 2013
Posts
23
Rep Power
0

#### Program sorting problem

Basically I wrote this program in which the user enters a number of numbers then each of those number and the program will return the value of the situations in which the maximum value is next to the minimum value or vice-versa.

Code:
```#include <stdio.h>
int main()
{
int n, i, nr=0;
float a[100], min, max;
printf("Enter number of values: ");
scanf("%d", &n);
printf("Enter values:\n");
for(i=0; i<n; i++)
scanf("%f", &a[i]); // citirea

min=a[0];
max=a[0];

for(i=0; i<n; i++)
if(a[i]<min) min=a[i];

for(i=0; i<n; i++)
if(a[i]>max) max=a[i];

for(i=0; i<n; i++)
if(a[i]==max && a[i+1]==min || a[i]==min && a[i+1]==max)
nr++;

printf("Number of situations: %d", nr);
getch();
return 0;
}```
Now basically I have to modify this program so that it sorts given values in order to have the maximum number of such situations. I tried something but it didn't work unless if there were more than two values verifiying the condition :(
2. Originally Posted by Cantafford
I tried something but it didn't work unless if there were more than two values verifiying the condition
OK, I'll wait for information of that to filter through the Astral Plane in the form of telepathic emanations from your mind to my Third Eye chakram. Unfortunately, I'm waiting for my new glasses, so until then I will have greater difficulty focusing my Third Eye. But that's alright. As long as you keep assuming that we can read your mind, we will assume the same thing and wait patiently for it to happen.

And for all the lower-evolved life-forms listening, the secret is to keep banging the rocks together.
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Jun 2013
Posts
23
Rep Power
0
Originally Posted by dwise1_aol
OK, I'll wait for information of that to filter through the Astral Plane in the form of telepathic emanations from your mind to my Third Eye chakram. Unfortunately, I'm waiting for my new glasses, so until then I will have greater difficulty focusing my Third Eye. But that's alright. As long as you keep assuming that we can read your mind, we will assume the same thing and wait patiently for it to happen.

And for all the lower-evolved life-forms listening, the secret is to keep banging the rocks together.
The example above, the code which I provided is the case to this.
4. Did you edit the OP or just double-down on vague?

You "tried something". How are we to divine what that was?
And how are we supposed to know what "it didn't work" is supposed to mean?

IOW, you are expecting us to read your mind and we can't.

Another example:
... the user enters a number of numbers then each of those number and the program will return the value of the situations in which the maximum value is next to the minimum value or vice-versa.
That is a confused and confusing mess, not an input specification. So now we're supposed to read your mind to determine what input values you're intending to test this with?

Provide us with sample input accompanied by the output that you expect. Then there can be no doubt about what you need. Why must it be such a foreign concept for you?

Until you do provide us with clear information that we need, you're forcing us to either read your mind or play guessing games with you. We do not have time for guessing games.