Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*lolsort*/
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main() {
- int block[5] [5];
- int fix[5] [5];
- int rowcount=0;
- int COLCOUNT=0;
- int TOTALCOUNT=0;
- int min;
- for(int row=0; row<5; row++) {
- for(int col=0; col<5; col++) {
- block[row] [col]=rand();
- }
- }
- while(TOTALCOUNT<25) {
- //get a value that has not been used
- for(int row=0; row<5; row++) {
- for(int col=0; col<5; col++) {
- if(block[row] [col]) min=block[row] [col];
- }
- }
- //compare to intial array
- for(int row=0; row<5; row++) {
- for(int col=0; col<5; col++) {
- if((block[row] [col]<min) && (block[row] [col]!=0)) min=block[row] [col];
- }
- }
- //put value in array in ascending order
- fix[rowcount] [COLCOUNT]=min;
- //remove from initial array
- for(int row=0; row<5; row++) {
- for(int col=0; col<5; col++) {
- if(block[row] [col]==min) block[row] [col]=0;
- }
- }
- TOTALCOUNT++;
- COLCOUNT++;
- if(COLCOUNT==5){
- COLCOUNT=0;
- rowcount++;
- }
- }
- //display
- for(int row=0; row<5; row++) {
- for(int col=0; col<5; col++) {
- cout << fix[row] [col] <<" ";
- }
- cout <<"\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement