U E D R , A S I H C RSS

이차함수그리기/조현태

느낀

3-4..
는..
.. ,, 뭐 .. .. ..
듯..
런데 모 는..
.. .
런데 .. ?ㅎ

데.
(y 25 . 25면 리는.. ..ㅎㅎ)tab .
면 TAB_Y 1 면 됨.
tab 1 , , 는데, 1 는..
!ㅎ( X..ㅎ)

리는 .;

~cpp 
#include <iostream>
#include <windows.h>

using namespace std;

const int MIN_X=-5;
const int MAX_X=5;
const float TAB_X=1;
const float TAB_Y=0.5;

int banollim(float number)
{
	//
	float temp_sosu=number-(int)number;
	if (temp_sosu<=-0.5 || temp_sosu>=0.5)
		++number;
	return number;
}

void gotoxy(int x, int y) 
{ 
	COORD Pos = {x - 1, y - 1}; 
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), Pos); 
}

float function_x_to_y(float x)
{
	// 
	float y=x*x;
	return y;
}

void make_image(int where_x, int where_y, float min_x, float max_x, float tab_x, float tab_y)
{
	//   x, y, x, x, x, y
	////.
	int max_y=0;
	int min_y=function_x_to_y(min_x);
	//y  
	for (register float x=min_x; x<=max_x; x+=tab_x)
	{
		if (max_y<function_x_to_y(x))
			max_y=function_x_to_y(x);
		else if (min_y>function_x_to_y(x))
			min_y=function_x_to_y(x);
	}
	////x,y 
	for (register float x=min_x; x<=max_x; ++x)
	{
		gotoxy(banollim(x-min_x+1+where_x),(where_y+max_y*tab_y));
		printf (".");
	}
	for (register float y=min_y; y<=max_y; ++y)
	{
		gotoxy(banollim(-min_x+1+where_x),(where_y-banollim(y)*tab_y+max_y*tab_y));
		printf (".");
	}
	//// 
	for (register float x=min_x; x<=max_x; x+=tab_x)
	{
		gotoxy(banollim(x-min_x+1+where_x),(where_y-banollim(function_x_to_y(x))*tab_y+max_y*tab_y));
		printf ("*");//(%.1f,%.1f)",x,function_x_to_y(x));
	}
}

void main()
{
	system("CLS");
	cout << "2  램.";
	make_image( 10 , 5 , MIN_X, MAX_X,TAB_X,TAB_Y);
	gotoxy(30,5);
	cout << "x      y";
	for (register int i=0; i<MAX_X-MIN_X+1;i+=1)
	{
		gotoxy(30,i+6);
		printf ("%3d  ->  %3.0f",i+MIN_X,function_x_to_y(i+MIN_X));
	}
}

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:30:33
Processing time 0.0106 sec