Pagini recente » Cod sursa (job #268095) | Cod sursa (job #757704) | Cod sursa (job #2097431) | template/ixia | Cod sursa (job #1435060)
// Cifra.cpp : Defines the entry point for the console application.
//
#include <stdlib.h>
#include <stdio.h>
#include "string"
#include "fstream"
int table[10] = { 1, 5, 2, 8, 3, 9, 2, 8, 7, 7};
using namespace std;
int main()
{
ifstream inFile("cifra.in");
ofstream outFile("cifra.out");
int T;
string str;
inFile >> T;
for (int i = 0; i < T; i++)
{
int beforeLast = 0, last = 0;
inFile >> str;
if (str.length() > 1){
last = (str[str.length() - 1] - '0');
beforeLast = (str[str.length() - 2] - '0') * 10;
}
else
{
last = str[str.length() - 1] - '0';
}
outFile <<(9 * beforeLast + table[last - 1] % 10) << "\n";
}
inFile.close();
outFile.close();
return 0;
}