/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
#include <cmath>
#include <sstream>
#include <fstream>
#include <typeinfo>
using namespace std;
int T ;
int F,L;
int thisNumber ;
int count ;
// Function to find that number divisble by 9 or not
int check(string str)
{
// Compute sum of digits
int n = str.length();
int digitSum = 0;
for (int i=0; i<n; i++)
digitSum += (str[i]-'0');
// Check if sum of digits is divisible by 9.
return (digitSum % 9 == 0);
}
bool is_integer(float k)
{
return std::floor(k) == k;
}
bool nine_test(int thisNumber)
{int thisDigit;
while (thisNumber != 0)
{
thisDigit = thisNumber % 10; // Always equal to the last digit of thisNumber
thisNumber = thisNumber / 10; // Always equal to thisNumber with the last digit
// chopped off, or 0 if thisNumber is less than 10
if (thisDigit == 9)
{
return(true);
}
}
return(false);
}
bool test(int k)
{
stringstream ss;
ss << k;
string str = ss.str();
if ( (!is_integer(k)) || (check(str)) || (nine_test(k)))
{
return (false);
}
return(true);
}
int main()
{
ifstream infile ("A_small_practice.txt");
ofstream myfile;
myfile.open("myfile.txt");
//infile.open("A-small-practice.txt");
infile >> T;
//std::cout <<"this is the T : "<< T <<" and this is the type : "<< typeid(T).name()<<std::endl;
for (int i=1; i<=T; ++i)
{
while(infile >> F >> L)
count = 0 ;
for (int j=F ; j<=L; ++j)
{
if (test(j))
{
count++;
}
}
cout << "Case #" << i << ": " << count << endl;
myfile << "Case #" << i << ": " << count << endl;
}
infile.close();
myfile.close();
return 0;
}