You are on page 1of 3

Subiectul 1

Ex2

#include <iostream>

using namespace std;

int main()

      unsigned x,z,y;

      cin>>x>>z;

      y=0;

      do

    { y=y*10+x%10;

      x=x/10;}

      while(x==0);

      while( (y*z>0) &&(y%10==z%10))

   {

              y=y/10;

              z=z/10;

   }

      if(y+z==0)

  

              cout<<1;

              else

              cout<<0;

   

Subiectul 2

Ex4
#include <string.h>

#include <iostream>

using namespace std;

int main()

      int i,j;

      char s[100],a;

      cin>>s;

      i=0;

      j=strlen(s)-1;

      while (i<j)

   {

              a=s[i];

              s[i]=s[j];

              s[j]=a;

              i=i+1;

              j=j-1;

   }

      for(i=0;i<=strlen(s)-1;i++)

      cout<<s[i];

Ex5

#include <string.h>

#include <iostream>
using namespace std;

int main()

      int i,j,n,m, a[100][100];

      cin>>n>>m;

      for(i=1;i<=n;i++)

      for(j=1;j<=m;j++)

      if(i<j)

      a[i][j]=j;

      else

      a[i][j]=i;

      for(i=1;i<=n;i++)

      {for(j=1;j<=m;j++)

      cout<<a[i][j]<<" ";

      cout<<endl;

   }

You might also like