Pagini recente » Cod sursa (job #2291092) | Cod sursa (job #3242714) | Cautari ortogonale | Cod sursa (job #1174944) | Cod sursa (job #3136469)
#include <fstream>
#include <cstdlib>
#include <cstring>
using namespace std;
ifstream f("cifra.in");
ofstream g("cifra.out");
int T;
int solve(int x)
{
if (x == 0 || x == 9)
return 7;
if (x == 1)
return 1;
if (x == 2)
return 5;
if (x == 3 || x == 7)
return 2;
if (x == 4 || x == 8)
return 8;
if (x == 5)
return 3;
return 9; ///x == 6
}
void citire()
{
f >> T;
while (T--)
{
char x[110];
f >> x;
int leng = strlen(x);
int val = atoi(x + (leng - 1));
g << solve(val) << '\n';
}
}
int main()
{
citire();
return 0;
}