U E D R , A S I H C RSS

새싹교실/2020/새싹부터나무까지/민기범/실습/20.10.02

1-1

#include <stdio.h>

int main()
{
	int number[10] = { 1,3,5,7,9,11,13,15,17,19 };
	int *p;

	for (int i = 0; i < 10; i++)
	{
		printf("%d\n", *(number+i));
	}
	return 0;
}

1-2

#include <stdio.h>

int main()
{
	int number[10] = { 1,3,5,7,9,11,13,15,17,19 };
	int* p = &number[0];

	for (int i = 0; i < 10; i++)
	{
		printf("%d\n", p[i]);
	}
	return 0;
}

1-3

#include <stdio.h>

int main()
{
	int number[10] = { 1,3,5,7,9,11,13,15,17,19 };
	int* p = &number[0];

	for (int i = 0; i < 10; i++)
	{
		printf("%d\n", *p++);
	}
	return 0;
}



2-1

#include <stdio.h>

int main()
{
	int number[3][4] = { {1,3,5,7},{9,11,13,15},{17,19,21,23} };
	int * p;
		
	for (int i = 0; i < 3; i++)
	{
		for(int j = 0; j < 4; j++)
		{
			printf("%d\n", *(*(number + i)+ j));
		}
	}
	return 0;
}

2-2

#include <stdio.h>

int main()
{
	int number[3][4] = { {1,3,5,7},{9,11,13,15},{17,19,21,23} };
	int * p = &number[0][0];

	for (int i = 0; i < 3; i++)
	{
		for(int j = 0; j < 4; j++)
		{
			printf("%d\n", *(p + i*4 + j));
		}
	}
	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-16 14:07:53
Processing time 0.0133 sec