user404 Posted April 1, 2016 Share Posted April 1, 2016 problem 3: find out from how many not falling sequences is the matrix made of e.g. 4 32 5 1 2 6 7 answer 3 solution: #include <stdio.h> int main(void){ int matrix[]={3,3,5,6,3,25,6,3,6,7,8,6}; //answer should be 5 int counter=1; int i; for(i=1; i<sizeof(matrix)/sizeof(matrix[0]); i++){ if(matrix[i-1]>matrix[i]) counter++; } printf(" %d sequences\n", counter); return 0; } ~ ~ ~ ~ Quote Link to comment Share on other sites More sharing options...
cooper Posted April 3, 2016 Share Posted April 3, 2016 Wow. That book really sucks. What a stupid way to pose a question and what a strange thing so assume the sequence 5, 4, 3, 2, 1 is 5 separate non-falling sequences as opposed to 1 continuously falling sequence. Quote Link to comment Share on other sites More sharing options...
user404 Posted April 4, 2016 Author Share Posted April 4, 2016 Eh, what can you do... it's from 1998! Quote Link to comment Share on other sites More sharing options...
cooper Posted April 5, 2016 Share Posted April 5, 2016 Now it might just be my grasp of the english language that is lacking here, but isn't a matrix a 2-dimensional array rather than 1? Quote Link to comment Share on other sites More sharing options...
user404 Posted April 5, 2016 Author Share Posted April 5, 2016 2-dimensional, 1xn :P Nah, you're right. Din engelsk er ok. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.