from [int] to [float]

hi guys
i have code, that swaps columns with minimum and maximum element
but i need to change the datatype numbers of matrix from int to the float
also (maybe if you know how) help me reduce this code...
pls help
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
  #include <stdio.h>
#include <conio.h>
 
void Change(int** matrix, int m, int n);
void Create(int m, int n, int i,int j);
void Out(int m, int n, int i, int j);
void Delete(int i,int m);
int** Matrix;
 
int main()
{
    int m, n; 
    int i, j; 
    printf("Input dimensions of a matrix: ");
    scanf_s("%i %i", &m, &n);
 
    Matrix = new int*[m];
    for(i = 0; i < m; i++)
    {
        Matrix[i] = new int[n];
    }
 
    Create(m,n,i,j);

    Out(m,n,i,j);
 
    Change(Matrix, m, n);
    printf("\n");

    Out(m,n,i,j);

    Delete(i,m);

    printf("Press any key to exit\n");
    _getch();
    return 0;
}
void Create(int m, int n, int i,int j)
	{
		for(i = 0; i < m; i++)
{
		for(j = 0; j < n; j++)
        {
            Matrix[i][j] = i + j;
        }
 }
}
void Out(int m, int n, int i, int j)
	{
		for(i = 0; i < m; i++)
       { for(j = 0; j < n; j++)
        {
            printf("%4i", Matrix[i][j]);
        }
        printf("\n");
		}
    }
void Change(int** matrix, int m, int n)
{
    int* minElements = new int[n];
    int* maxElements = new int[n];
 
    for(int j = 0; j < n; j++)
    {
        int minElement = matrix[0][j];
        int maxElement = matrix[0][j];
        for(int i = 0; i < m; i++)
        {
            if(minElement > matrix[i][j])
            {
                minElement = matrix[i][j];
            }
            if(maxElement < matrix[i][j])
            {
                maxElement = matrix[i][j];
            }
        }
        minElements[j] = minElement;
        maxElements[j] = maxElement;
    }
 
    int minCol = 0, maxCol = 0;
    int absoluteMin = minElements[0];
    int absoluteMax = maxElements[0];
 
    for(int j = 0; j < n; j++)
    {
        if(minElements[j] < absoluteMin)
        {
            absoluteMin = minElements[j];
            minCol = j;
        }
        if(maxElements[j] > absoluteMax)
        {
            absoluteMax = maxElements[j];
            maxCol = j;
        }
    }
 
    int temp;
    for(int i = 0; i < m; i++)
    {
        temp = matrix[i][minCol];
        matrix[i][minCol] = matrix[i][maxCol];
        matrix[i][maxCol] = temp;
    }
 
    delete minElements;
    delete maxElements;
}
void Delete(int i,int m)
	{
		for(i = 0; i < m; i++)
    {
        delete Matrix[i];
    }
    delete Matrix;
}
Topic archived. No new replies allowed.