Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.63 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.     void readtab(float x[][100], int n, int m){
  5.     int i,j;
  6.     for (i=0;i<n;i++){
  7.     for (j=0;j<m;j++){
  8.     printf(" x[%d][%d]=",i,j);
  9.     scanf("%f",&x[i][j]);
  10.        }
  11.     }
  12.     }
  13.  
  14.    void showtab(float x[][100], int n, int m){
  15.     int i,j;
  16.     printf("\n");
  17.     for (i=0; i<n; i++){
  18.     for (j=0; j<m; j++ ){
  19.         printf(" %.0f ",x[i][j]);
  20.    }
  21.     printf("\n");
  22.    }
  23.     printf("\n");
  24. }
  25.  
  26.     void vector(float x[][100], float B[5000],int n, int m){
  27.     int A = 0;
  28.     int i,j;
  29.      
  30.           for(j = 0; j < m; j++){
  31.             if (x[0][j]){
  32.                 B[A++] = x[i][j];      
  33.        }
  34.     }    
  35.   }
  36.  
  37.   void vectorSecond(float x[][100], float B[5000],int n, int m){
  38.     int A = 0;
  39.     int i,j;
  40.       for(j = 0; j < n; j++)
  41.           for(i = n-1; i < m; i++){
  42.             if (x[i][j]){
  43.                 B[A++] = x[i][j];      
  44.        }
  45.     }    
  46.  
  47.    for (i = 0; i < A; i++){
  48.         if(B[i]==0){
  49.             break;
  50.         }
  51.         printf(" %.0f ", B[i]);
  52.     }
  53.   }
  54.    
  55.     void showvector(float B[5000]){
  56.     int i,j;
  57.     int A;
  58.     printf("\n Elementele Vectorului B sunt: ");
  59.     for (i = 0; i < A; i++){
  60.         if(B[i]==0){
  61.             break;
  62.         }
  63.         printf(" %.0f", B[i]);
  64.     }
  65.  }
  66.  
  67.  int main(){
  68.     float x[100][100],B[5000];
  69.     int n,m;
  70.     printf("\n Dati numarul de linii: ");
  71.     scanf("%d", &n);
  72.     printf("\n Dati numarul de coloane: ");
  73.     scanf("%d", &m);
  74.     printf("\n");
  75.     readtab(x,n,m);
  76.     showtab(x,n,m);
  77.     vector(x,B,n,m);
  78.     showvector(B);
  79.     vectorSecond(x,B,n,m);
  80.     return 0;
  81.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement