U E D R , A S I H C RSS

새싹교실/2014/배반/6주차 (rev. 1.10)

새싹교실/2014/배반/6주차


1. 개요

2. 내용

  • 포인터 오세상에올것이왔어
  • 망했다고 합니다. 이해하기 너무 힘든 듯.
  • 하지만 이번 주가 끝이 아니라고 합니다.후후후후후후후

3. 과제

캡처.PNG
[PNG image (16.72 KB)]

Problem?
이 과제를 김승태교수님에게 바칩니다

  • 단, 3~9 말고 3~11
  • 이거 하고
  • 할 수 있으면 배열을 통한 접근과 포인터를 이용한 접근 둘 다 해볼 것
  • 그리고 정수 대신에 주소값을 출력하는 것도 해볼 것
    • 이를 통해 주소값이 어떻게 배치되어 있는 지를 알 수 있음
  • 달팽이를 출력하는 부분은 꼭 함수로 만들 것.

4. 제출 내용


4.1. 임기찬


4.2. 홍성현


#include <stdio.h>
#define SIZE 10

int MAPSIZESIZE = {0};
void PrintMap(int);
void Spin(int);

int main()
{
int n;
printf("n을 입력해주세요");
scanf("%d",&n);
Spin(n);
PrintMap(n);
return 0;
}

void PrintMap(int n)
{
int i,j;
i=j=n;

for(i = 0 ; i < n ; i++)
{
for(j = 0 ; j < n ; j++)
{
printf("%d",MAPij);
}
printf("\n");
}
}

void Spin(int n)
{
int i,j,k,AllCount,x,y,num=1 ;
float SomeCount =1.0;

if(n%2==1)
k=n/2;
else
k=n/2 -1;

x=0,y=0;
while(1)
{
//오른쪽
for(i=0 ; i < (int)SomeCount ;)
{
MAPxy=num;
y++;
num++;
}
SomeCount+=0.5;
AllCount--;
y--;
if(AllCount ==0)
break;
else if(AllCount ==1)
SomeCount--;

//아래쪽
for(i=0 ; i < (int)SomeCount ;)
{
MAPxy=num;
x++;
num++;
}
SomeCount+=0.5;
AllCount--;
x--;
if(AllCount ==0)
break;
else if(AllCount ==1)
SomeCount--;

//왼쪽
for(i=0 ; i < (int)SomeCount ;)
{
MAPxy=num;
y--;
num++;
}
SomeCount+=0.5;
AllCount--;
y++;
if(AllCount ==0)
break;
else if(AllCount ==1)
SomeCount--;

//위쪽
for(i=0 ; i < (int)SomeCount ;)
{
MAPxy=num;
x--;
num++;
}
SomeCount+=0.5;
AllCount--;
x++;
if(AllCount ==0)
break;
else if(AllCount ==1)
SomeCount--;
}
}




Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:51
Processing time 0.0254 sec