배열

6,9 따로 떼고 생각해보자 #include using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int cnt[10]={}; while(n>0){ cnt[n%10]++; n/=10; } int set = 1; for(int i =0; i < 10; i++){ if(i == 6 || i == 9) continue; set = max(set,cnt[i]); } set = max(set, (cnt[6]+cnt[9]+1) / 2); cout
풀이1 int를 문자열로 바꾸는것을 통해 아스키코드값을 이용하여 풀 수 있다. #include using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0); int a, b, c; int cnt[10]={}; cin >> a >> b >> c; int res = a * b * c; /* std::to_string(val) 숫자(int, long, float, double 등)를 문자열(string)으로 변환하여 반환해주는 함수를 사용한다. */ string s = to_string(res); for( auto x : s){ cnt[x - '0']++; } for( auto y : cnt){ cout a >> b >> c; int res = a..
Roble
'배열' 태그의 글 목록