목록설명 (73)
안경잡이 구루루
나: def new_num(): All =[] n=0 for i in range(1,10001): All.append(i) for k in range(10000): n += 1 new=0 new = new+ int(n) for i in range(len(str(n))): new += int(str(n)[i]) if new in All: All.remove(new) for i in All: print(i) new_num() 완성된 코드는 위와 같다. def new_num(): All =[] self=[] n=0 for i in range(1,10001): All.append(i) 위는 셀프넘인지 판단하기 이전에 설정하는 기본 설정부분이다. 새로운 수를 생성하는 new_num이라는 함수를 만든다. 1만까지 ..
나: def solve(a): ans = sum(a) return ans 완성된 코드는 위와 같다. 위 문제를 보면 입력값으로 받는 a는 list라고 알려주고 있다. 즉 n개의 정수를 갖고 있는 리스트의 총 합을 구하면 된다. sum 함수를 이용해서 리스트의 총합을 ans에 대입하고 이것을 return 으로 출력한다. 다른사람: https://claude-u.tistory.com/107 def solve(num_list): result = 0 for num in num_list: result += num return result 완성된 코드는 위와 같다. 살펴봐야 될 부분은 sum함수 대신에 for 반복문을 이용해서 입력값으로 받은 num_list에 들어있는 요소들의 합을 하나씩 result에 더해나갔다.
나(오답): #include int main() { int a, b, c, mul,lum,cnt=0; char num[10] = { 0, }; scanf_s("%d\n %d\n %d",&a,&b,&c); mul = a * b * c; while (mul > 0) { mul /= 10; cnt++; } for (int i = 0; i < cnt; i++) { lum = mul % 10; num[lum] += 1; mul = mul / 10; } for (int j = 0; j < 10; j++) { printf("%d\n", num[j]); } } 오답인 코드는 다음과 같다. 숫자들을 최종으로 곱한 값 mul의 길이만큼 for 반복을 이용해 나머지값들을 배열의 각 자리에 1씩 더한다고 생각 그러나 결과값은..
나: C = int(input()) for i in range(C): score = list(map(int, input().split())) cnt =0 if score[0] == len(score)-1: aver = (sum(score)-score[0]) / score[0] for j in range(1,len(score)): if aver < score[j]: cnt +=1 print('%0.3f%%'%((cnt/score[0])*100)) 완성된 코드는 위와 같다. C = int(input()) for i in range(C): score = list(map(int, input().split())) cnt =0 if score[0] == len(score)-1: aver = (sum(score)-s..