2017.08.17 23:21
2020.10.18 18:16
어디가 잘못됐나요?
--------------------
max, thing = input().split()
max, thing = int(max), int(thing)
ghf = []
wkr = []
c= 0
for i in range(max):
if (i//thing)%2 == 0:
ghf.append(i+1)
elif (i//thing)%2 == 1:
wkr.insert(0, i+1)
for j in range(max):
if (j//thing)%2 == 1:
ghf.insert(j, wkr[c])
c+= 1
if (max//thing)%2 == 0:
for k in range(max):
if ghf[k]<10:
print('0%d' %(ghf[k]), end=' ')
else:
print('%d' %(ghf[k]), end=' ')
if k%(thing) == (thing-1):
print('\n', end ='')
else:
z= max//thing
y= max%thing
for l in range(thing-y):
ghf.insert(z*thing, ' ')
for m in range(z*thing):
if ghf[m]<10:
print('0%d' %(ghf[m]), end=' ')
else:
print('%d' %(ghf[m]), end=' ')
if m%(thing) == (thing-1):
print('\n', end ='')
for n in range(z*thing, len(ghf), 1):
if type(ghf[n])==int:
if ghf[n]<10:
print('0%d' %(ghf[n]), end=' ')
else:
print('%d' %(ghf[n]), end=' ')
else:
print(ghf[n], end=' ')
안녕하세요 아래의 코드는 제 부모님이도와주신 코드입니다. 무었이 틀렸는지 알려주세요. 답장 부탁드립니다.
-----------------------------------------------------------------------------------------------
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
int m, i, n, count, decrease, line, temp, now;
m = 0;
n = 0;
count = 0;
line = 1;
scanf("%d %d", &m, &n);
decrease = n - 1;
for (i = 1; i <= m; i++){
count++;
temp = i;
// if line is even, do below if statement
if (line % 2 == 0){
temp = temp + decrease;
decrease = decrease - 2;
}
// change line if you display n numbers.
/*
if(count%n==0) {
line++;
printf("%02dn",temp);
}
else
*/
if (m < 10)
printf("%d ", temp);
else if (m < 100)
printf("%02d ", temp);
else
printf("%03d ", temp);
if (count % n == 0){
line++;
printf("n");
}
// if this line is next line, set decrease value again.
if (count % n == 0) decrease = n - 1;
// think last line. (sometime last line is not full)
now = m - count;
if ((count % n == 0) && (now < n)) decrease = now - 1;
}
return 0;
}