Initial commit
This commit is contained in:
53
2022/sector/code/code.cpp
Normal file
53
2022/sector/code/code.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
ifstream input_stream;
|
||||
ofstream output_stream;
|
||||
|
||||
|
||||
uint16_t generateNumber(uint16_t first, uint16_t second, uint16_t third, uint16_t fourth) {
|
||||
return first * 1000 + second * 100 + third * 10 + fourth;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main() {
|
||||
input_stream.open("input.txt");
|
||||
output_stream.open("output.txt");
|
||||
|
||||
uint16_t first, third;
|
||||
// File method:
|
||||
// input_stream >> first;
|
||||
// input_stream >> third;
|
||||
// Console method:
|
||||
cin >> first;
|
||||
cin >> third;
|
||||
|
||||
uint16_t total = 0;
|
||||
|
||||
for (uint16_t second = 0; second <= 9; second++) {
|
||||
for (uint16_t fourth = 0; fourth <= 9; fourth++) {
|
||||
uint16_t generatedNumber = generateNumber(first, second, third, fourth);
|
||||
if (generatedNumber % 9 == 0) {
|
||||
// File method:
|
||||
// output_stream << generatedNumber << endl;
|
||||
// Console method:
|
||||
cout << generatedNumber << endl;
|
||||
total++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// File method:
|
||||
// output_stream << total << endl;
|
||||
// Console method:
|
||||
cout << total << endl;
|
||||
|
||||
input_stream.close();
|
||||
output_stream.close();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user