source: liacs/pm/tentamen_oef/opgave1.cc@ 324

Last change on this file since 324 was 2, checked in by Rick van der Zwet, 15 years ago

Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)

  • Property svn:executable set to *
File size: 941 bytes
RevLine 
[2]1#include <iostream>
2
3using namespace std;
4
5
6int kleinste( const int a[], const int i, const int n ) {
7 int tmpKleinste = i;
8 for(int ctr =(i+1); ctr < n; ctr++ ) {
9 if( a[ctr] < a[tmpKleinste] ) {
10 tmpKleinste = ctr;
11 }
12 }
13 return tmpKleinste;
14}
15
16void verschuif( int a[], const int i, const int j ) {
17 const int tmpGetal = a[j];
18 for(int ctr = j; ctr > i; ctr--) {
19 a[ctr] = a[ctr-1];
20 }
21 a[i] = tmpGetal;
22}
23
24void sorteer( int a[], const int n ) {
25 int tmpKleinste = 0;
26 for(int ctr = 0; ctr < n; ctr++) {
27 tmpKleinste = kleinste( a, ctr, n );
28 cout << "Kleinste = " << tmpKleinste <<endl;
29 verschuif( a ,ctr, tmpKleinste );
30 }
31}
32
33int const n = 3;
34
35void groter( int a[][n], const int X, const int m ) {
36cout << n;
37}
38
39int main( ) {
40/* int a[6] = {2,4,1,5,3,6};
41 sorteer( a, 6 );
42 for(int ctr=0; ctr< 6; ctr++) {
43 cout << a[ctr] <<endl;
44 }
45*/
46
47int a[3][3] = { { 3, 5, 7 } , { 1, 2, 5 } , { 7, 7, 11} };
48groter(a, 4, 1);
49
50} //end main
Note: See TracBrowser for help on using the repository browser.