예제부터 넣어보세요.
4276번 - 0이 몇 개?
예제부터 넣어보세요.
int를 사용한 코드도 올려주실 수 있나요?
ㄴ 네 아래와 같습니다..
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;
int Ao(int c);
int main()
{
int m = 6;
for (int i = 0; i <= m; i++) {
int a, b;
int result = 0;
cin >> a >> b;
if (a < 0) { return 0; }
for (int i = a; i <= b; i++) {
result += Ao(i); //
}
cout << result << "\n";
}
}
int Ao(int c) {
int count = 0;
int i = 0;
string S;
S = to_string(c); // 숫자를 스트링으로 "바꿔서" 이어나감
for (int j = 0; j < S.size(); j++) {
if (S[j] == '0') {
count++;
}
}
return count;
}
댓글을 작성하려면 로그인해야 합니다.
rosmano 1년 전
여기서 뭐가 틀렸나요? 돔좀 부탁드립니다 unsigned int 까다롭네요