zj3t

email: euntaejang@gmail.com

Latest Posts

Project Euler-6

By 오후 1:19

이 문제도 쉬운 문제였습니다 코드보면 이해가 가실거에요~~



#include <stdio.h>

int pows(int x) {
int result=1;
for (int i = 0; i < 2; i++) {
result *= x;
}
return result;
}

int main() {
unsigned long long square_of_sum = 0;
unsigned long long sum_of_square = 0;
unsigned long long sum = 0;
unsigned long long result = 0;

for (int i = 1; i <= 100; i++) {
sum_of_square += pows(i);
}
for (int i = 1; i <= 100; i++) {
sum += i;
}
square_of_sum = pows(sum);
result = square_of_sum - sum_of_square;

printf("result= %I64u\n", result);

return 0;
}

You Might Also Like

0 개의 댓글