Digit Generator

 avatar
user_3763047219
c_cpp
2 years ago
506 B
2
Indexable
Never
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>

int main()
{
	int n = 0;
	scanf("%d", &n);
	int num[100000] = { 0 };
	for (int i = 0; i < n; i++) {
		scanf("%d", &num[i]);
	}
	for (int k = 0; k < n; k++) {
		for (int j = 1; j <= num[k]; j++) {
			int j2 = j;
			int j3 = j;
			while (j2 != 0) {
				j3 = j3 + j2 % 10;
				j2 = j2 / 10;
			}
			if (j3 == num[k]) {
				printf("%d\n", j);
				break;
			}
			if (j == num[k] && j3 != num[k]) {
				printf("0\n");
			}
		}
	}
}