c programming number sorting
Go to solution
Solved by fizzlesticks,
Assuming I understand the problem, this may help.
float numbers[] = { 43,54,1,64,234,54,23,4,65,3453,234,543,...} // with 500 numbersint main(){ int numValid = 0; int numInvalid = 0; float validNumbers[500]; float invalidNumbers[500]; loop through numbers array { if the number is 150<x<200 { add the number to the validNumbers array add 1 to numValid } else { add the number to the invalidNumbers array add 1 to numInvalid } } //look up qsort for sorting qsort validNumbers from index 0 to numValid qsort invalidNumbers from index 0 to numInvalid printf validNumbers printf invalidNumbers //if the sorted lists need to be printed loop from 0 to numValid { printf validNumber[x] } loop from 0 to numInvalid { printf invalidNumber[x] } return 0;}
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now