Cod sursa(job #178378)

Utilizator RoflmaoPatru Ovidiu Roflmao Data 14 aprilie 2008 14:46:48
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.69 kb
#include<fstream.h>
#include<iostream.h>
#include<math.h>
#include<stdio.h>
int main(void)
{
  long int t,r,i,j,x[10],m,n,coun,h;
  fstream f,g;
  char y[105];
  x[0]=0; x[1]=1; x[2]=5; x[3]=2; x[4]=8;
  x[5]=3; x[6]=9; x[7]=2; x[8]=8; x[9]=7;
  f.open("cifra.in",ios::in);
  g.open("cifra.out",ios::out);
  f>>t;
  f.getline(y,105);
  for(i=1;i<=t;i++)
  {
    r=0;
    for(j=0;j<105;j++)
      y[j]='a';
    f.getline(y,105);
    coun=0;
    while(y[coun]!='a')
      coun++;
    coun--;
    r=y[coun-1]-48;
    if(coun>1)
      r=r+(y[coun-2]-48)*10;
    m=x[r%10];
    n=7*((r%100)/10);
    m=(m+n)%10;
    g<<m<<"\n";
  }
  f.close();
  g.close();
  return 0;
}