Cod sursa(job #2267804)

Utilizator CristianGabriel18Cristian-Gabriel CristianGabriel18 Data 24 octombrie 2018 01:33:58
Problema Cifra Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <iostream>
#include <string>
#include <fstream>
using namespace std;

int main()
{
	ifstream fin("cifra.in");
	ofstream fout("cifra.out");

	int v[101] = { 0, 1, 5, 2, 8, 3, 9, 2, 8, 7, 7, 8, 4, 7, 3, 8, 4, 1, 5, 4, 4, 5, 9, 6, 2};
	int t;
	string n;

	fin >> t;
	int a;
	for (int i = 1; i <= t; i++)
	{
		fin >> n;

		int length = n.size();
		if (length == 1)
		{
			a = n[0] - '0';
		}
		else if (length >= 2)
		{
			a = (n[length - 2] - '0') * 10 + (n[length - 1] - '0');
		}
		fout << v[a] << endl;
	}
	return 0;
}