SHARE
TWEET

Proiect3

a guest Apr 24th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int a[20][20];
  5. int n,m,i,j,s,p,nr,d,dif;
  6. int citire(int &n, int a[][20])
  7. {
  8.   cout<<"n= ";
  9.   cin>>n;
  10.   for(i=1;i<=n;i++)
  11.   for(j=1;j<=n;j++)
  12.   {
  13.       cout<<"a["<<i<<"]["<<j<<"]= ";
  14.   cin>>a[i][j];
  15.   }
  16. }
  17. int afisare(int n, int a[][20])
  18. {
  19.     cout<<" afisare "<<endl;
  20.     for(i=1;i<=n;i++)
  21.     {
  22.         for(j=1;j<=n;j++)
  23.     cout<<a[i][j]<<" ";
  24.     cout<<endl;
  25.  
  26.     }
  27.     }
  28.  
  29. int suma(int n, int a[][20])
  30. {
  31.   for(i=1;i<=n;i++)
  32.         for(j=1;j<=n;j++)
  33.         if(i==j)
  34.         s=a[i][j]+s;
  35.         cout<<s<<" ";
  36. }
  37.   int produs(int n, int a[][20])
  38.   {    p=1;
  39.       for(i=1;i<=n;i++)
  40.         for(j=1;j<=n;j++)
  41.         if(i+j==n+1)
  42.         p=a[i][j]*p;
  43.         cout<<p<<" ";
  44.   }
  45.   int prime(int n, int[][20])
  46.   {
  47.       for(i=1;i<=n;i++)
  48.         for(j=1;j<=n;j++)
  49.         {
  50.             nr=0;
  51.         for(d=2;d<=a[i][j]/2;d++)
  52.         if(a[i][j]%d==0)
  53.         nr=nr+1;
  54.       if(nr==0)
  55.         cout<<endl<<a[i][j]<<" ";}
  56.  
  57.   }
  58. int main()
  59. {
  60.     //citire(n,a);
  61.     //afisare(n,a);
  62.     //suma(n,a);
  63.     //produs(n,a);
  64.  
  65.     //prime(n,a);
  66.  
  67.    cout<<"n="<<" ";
  68.    cin>>n;
  69.    cout<<"m="<<" ";
  70.    cin>>m;
  71.    for(i=1;i<=n;i++)
  72.     for(j=1;j<=m;j++)
  73.     {cout<<"a["<<i<<"]["<<j<<"]=";
  74.     cin>>a[i][j];}
  75.     cout<<"matricea este=";
  76.     for(i=1;i<=n;i++)
  77.     {
  78.       for(j=1;j<=m;j++)
  79.         cout<<a[i][j]<<" ";
  80.         cout<<endl;
  81.     }
  82. p=1;
  83.     for(j=1;j<=m;j++)
  84.     {s=s+a[1][j];
  85.     p=p*a[2][j];
  86.     dif=dif-a[3][j];
  87.     }
  88.     cout<<"s="<<s<<" p= "<<p<<" dif="<<dif;
  89.    return 0;
  90. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top