Cod sursa(job #1828398)

Utilizator SorinSalamSorinSalam SorinSalam Data 13 decembrie 2016 11:01:59
Problema Cifra Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.71 kb
#include<iostream>
#include <algorithm>
#include <fstream>
#include <cstring>
using namespace std;
int U(int b)
{
    b=b%10;
    if (b==0) return 0;
   else if (b==1) return 1;
    else if (b==2) return 4;
    else if (b==3) return 7;
    else if (b==4) return 6;
    else if (b==5) return 5;
    else if (b==6) return 6;
    else if (b==7) return 3;
    else if (b==8) return 6;
    else if (b==9) return 9;
}

int main ()
{
  ifstream f("cifra.in");
  ofstream g("cifra.out");
  int n,s=0;
  int t;
  f>>t;
  int i,j;
  for (i=1;i<=t;i++)
  {
      f>>n;
      s=0;
      for (j=1;j<=n;j++)
      {
          s=s+U(j);
      }
      s=s%10;
      g<<s<<'\n';
  }
    return 0;
}