자료구조 공부하고있는데 여기서 물어봐도 되나요?? 채택완료
엥호
6년 전
조회 3,426
For each of the followings, state the precondition or/and postcondition.
(1) if (x >= 0) y = x + y;
else y = y - x;
2) /* precondition: m <= n */
s = 0;
for (i = m; i <= n; i++)
s += i;
(3) i = 1;
c = 0;
while (i <= n)
if (a[i] == 17)
{c = c + 1;
i = i + 1;
}
else i = i + 1;
(4) m = a[1];
i = 2;
while (i <= n)
if (a[i] > m) m = a[i];
else i = i +1;
2. State the postcondition and loop invariant for the following code.
/* precondition: 1 <= b */
i = 1;
c = 1;
while (i <= b)
{c = c * a;
i++;}
따로 독학중인데 너무 어려워서 답안하고 풀이좀 여쭤봐도되나요?
댓글을 작성하려면 로그인이 필요합니다.
답변 1개
답변을 작성하려면 로그인이 필요합니다.
로그인
다급하게 물어만 보았네요 ㅎㅎ