BubbleSort 2D array keeping rows together

hi, im having trouble sorting this array by Y from the highest to the lowest but i need to keep all the data in the same row together, help pls

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
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;



int main()
{
	
	int redovalnica [10][5];
	srand(time(0));
	cout << "Student - KV  - RV  - VI  - OC "<<endl;	
	
	for(int x=0; x<10; x++)
	{
		int y=0;
		redovalnica[x][0]=x+1;
		cout << redovalnica[x][0] << " ------ ";
		 
		for(int i=1; i<4; i++)
		{
			redovalnica[x][i]=rand()%101;
			cout <<redovalnica[x][i]<<"% - ";
			
			if(i==1){
				y=y+(0.15*redovalnica[x][i]);
			}
			else if(i==2){
				y=y+(0.35*redovalnica[x][i]);
			}
			else if(i==3){
				y=y+(0.50*redovalnica[x][i]);
				
					if(0<y && y<10){
						y=1;
					cout<<y;
					}
					else if(9<y && y<20){
						y=2;
					cout<<y;
					}
					else if(19<y && y<30){
						y=3;
					cout<<y;
					}
					else if(29<y && y<40){
						y=4;
					cout<<y;
					}
					else if(39<y && y<50){
						y=5;
					cout<<y;
					}
					else if(49<y && y<60){
						y=6;
					cout<<y;
					}
					else if(59<y && y<70){
						y=7;
					cout<<y;
					}
					else if(69<y && y<80){
						y=8;
					cout<<y;
					}
					else if(79<y && y<90){
						y=9;
					cout<<y;
					}
					else if(89<y && y<100){
						y=10;
					cout<<y;
					}
			}
			
		}
		cout<<endl;
	}
	
	
}

	
Topic archived. No new replies allowed.