Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <stdio.h>
- #include <conio.h>
- const int l=12;
- const int m=14;
- const int n=25;
- int H[l][m];
- int P[l];
- bool ready;
- int func(int n, int *A){
- for(int i = n-1; i >=0; i--){
- if(A[i]<0){
- return A[i];
- }
- }
- return 1;
- }
- void buble_sort(){
- bool ready = false;
- int temp;
- while(!ready){
- ready = true;
- for(int i = 0; i < l-1; i++){
- if(P[i+1] < P[i]){
- temp = P[i];
- P[i] = P[i+1];
- P[i+1] = temp;
- ready = false;
- }
- }
- }
- }
- int _tmain(int argc, _TCHAR* argv[]){
- for(int i = 0; i < l; i++){
- for(int j = 0; j < m; j++){
- scanf("%d", &H[i][j]);
- }
- }
- for(int i = 0; i < l; i++){
- P[i] = func(l, H[i]);
- if(P[i] < 0){
- ready = true;
- }
- }
- if(!ready){
- printf("В матрице нет отрицательных чисел\n");
- return 0;
- }else{
- buble_sort();
- for(int i = 0; i < l; i++){
- printf("%d ", &P[i]);
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement