Advertisement
icatalin

tema 18.9 prima cifra in loc de max

Sep 24th, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. ifstream f("date.in");
  7. ofstream g("date.out");
  8.  
  9. int main()
  10. {
  11.     int a[100][100],i,j,m,n,pc,ogl,cop,con,nr,q;
  12.     f>>m>>n;//m-linii,n-coloane
  13.     for (i=1;i<=n;i++)
  14.     for (j=1;j<=m;j++)
  15.     {
  16.         f>>a[i][j];
  17.         if (j%2==1)
  18.         {
  19.             cop=a[i][j];
  20.             con=0;
  21.             ogl=0;
  22.             while (cop)
  23.             {
  24.                 ogl=ogl*10+cop%10;
  25.                 cop=cop/10;
  26.                 con++;
  27.             }
  28.         pc=ogl%10;
  29.         nr=0;
  30.         for (q=1;q<=con;q++)
  31.         nr=nr*10+pc;
  32.         a[i][j]=nr;
  33.         }
  34.     }
  35.     for (i=1;i<=n;i++)
  36.     {
  37.         for (j=1;j<=m;j++)
  38.         g<<a[i][j]<<" ";
  39.         g<<'\n';
  40.     }
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement