I made the change that you told me, but I still have the same problem...
Code:
1. # define N 10
2. # include <iostream>
3. # include <stdlib.h>
4. using namespace std;
5.
6. pos_max int (int t [], int p);
7. int main ()
8. (
9. srand (NULL);
10. int t [N];
11. int m;
12. / / Making the array.
13. for (int i = 0; i <N; i + +)
14. (
15.
16. t [i] = rand ()% 9;
17. court <<t [i] << "";
18. )
19. court <<endl;
20.
21.
22.
23. for (m = 0, m <N, m + +)
24. (
25. court <<m << "" <<N <<endl;
26. int p = pos_max (t, Nm-1);
27. court <<p <<endl;
28. int to = t [p];
29. t [p] = t [Nm-1];
30. t [Nm-1] = aux;
31. )
32. for (int i = 0; i <N; i + +)
33. (
34. court <<t [i] << "";
35. )
36. return 0;
37. )
38. pos_max int (int t, int p)
39. (
40. int pmax = 0;
41. for (int i = 0; i <p; i + +)
42. (
43. if (t [i]> t [pmax])
44. (
45. pmax = i;
46. )
47. )
48. return pmax;49. )
Bookmarks