Pagini recente » Cod sursa (job #1471895) | Cod sursa (job #1211635) | Cod sursa (job #2976978) | Cod sursa (job #2264992) | Cod sursa (job #1435066)
// Cifra.cpp : Defines the entry point for the console application.
//
#include <stdlib.h>
#include <stdio.h>
#include "string"
#include "fstream"
#include <iostream>
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');
}
else
{
last = str[str.length() - 1] - '0';
}
if (last > 0)
outFile << (7 * beforeLast + table[last - 1]) % 10 << "\n";
else
outFile << (7 * beforeLast) % 10 << "\n";
}
inFile.close();
outFile.close();
return 0;
}