전체 글

분석할 코드 : #include int strchr(char *str, char ch) { int idx = 0; while (*str) { if (*str == ch) return idx; str++; idx++; } return -1; } int rstrchr(char *str, char ch) { int idx; for (idx = 0; str[idx] != '\0'; idx++) ; for (idx--; idx >= 0; idx--) if (str[idx] == ch) return idx; return -1; } void main(void) { char str[ ] = "university"; printf("%d", strchr(str, 'i')); printf("%d", rstrchr(str, ..
15740번: A+B - 9 (acmicpc.net) from sys import stdin # 시간 최소화를 위해 sys 사용 A, B = map(int, stdin.readline().split()) # 여러개의 타입을 변경해야 하므로 map 사용 print(A + B) 1008번: A/B (acmicpc.net) from sys import stdin A, B = map(int, stdin.readline().split()) print(A / B) 2884번: 알람 시계 (acmicpc.net) from sys import stdin H, M = map(int, stdin.readline().split()) if M >= 45: print(H, M - 45) elif H > 0 and M < 45:..
C언어에서 배열은 아래와 같은 구조로 선언할 수 있습니다. int array1[3]; // 3 크기를 가진 array1 이라는 배열 int array2[5] = { 10, 20, 30, 40, 50 }; // 5 크기를 가진 array2 라는 배열에 순서대로 10, 20, 30, 40, 50을 넣은 모습 int array3[] = { 10, 20, 30, 40, 50 }; // 이럴 경우 크기를 생략할 수 있습니다. array2와 같이 값을 무조건 넣어줘야 합니다. int array4[]; // 오류 발생 일반적으로 배열을 선언할 때에는 크기 (대괄호 안의 숫자)를 반드시 지정해야 합니다. 또 중괄호를 사용하여 배열에 값을 넣을 경우에는 지정한 크기보다 큰 값 개수를 넣어서는 안 됩니다. 예를 들어, a..
for 문의 일반적인 형식이라면 이런 형식일 것이다. for (int i = 1; i