Little Jay

[C++] 백준 11170번 0의 개수 본문

알고리즘/BOJ

[C++] 백준 11170번 0의 개수

Jay, Lee 2021. 3. 25. 15:25
#include <iostream>
#include <string>
using namespace std;

int main() {

	int testcase, a, b;
	cin >> testcase;
	

	for (int p = 0; p < testcase; p++) {
		cin >> a >> b;
		int repeated = 0;
		for (int i = a; i <= b; i++) {
			string num = to_string(i);
			for (int k = 0; k < num.length(); k++) {
				if (num[k] == '0')
					repeated++;
			}
		}
		cout << repeated << "\n";
	}

	return 0;
}

 

Comments