Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int max(int*, int);
- void sort(int*, int);
- int main()
- {
- printf("Uslovieto\n");
- printf("My name\n");
- int size = 0;
- scanf("%d", &size);
- int array[size][size];
- for(int counter = 0; counter < size; counter++){
- for(int index = 0; index < size; index++){
- scanf("%d", &array[counter][index]);
- }
- }
- //print the data entered
- for(int counter = 0; counter < size; counter++){
- for(int index = 0; index < size; index++){
- printf("%d ", array[counter][index]);
- }
- printf("\n");
- }
- int one_dimension_array[size];
- for(int counter = 0; counter < size; counter++){
- one_dimension_array[counter] = max(array[counter], size);
- }
- // print the array
- for(int counter = 0; counter < size; counter++){
- printf("%d\n", one_dimension_array[counter]);
- }
- //print the array sorted
- sort(one_dimension_array, size);
- for(int counter = 0; counter < size; counter++){
- printf("%d\n", one_dimension_array[counter]);
- }
- return 0;
- }
- int max(int* array, int size){
- int max_number = array[0];
- for(int counter = 1; counter < size; counter++){
- if(max_number < array[counter]) max_number = array[counter];
- }
- return max_number;
- }
- void sort(int* array, int size){
- for(int counter = 0; counter < size; counter++){
- for(int index = 1; index < size; index++){
- if(array[counter] > array[index]){
- int temp = array[counter];
- array[counter] = array[index];
- array[index] = temp;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement