본문내용
ntf(\"\\n\");
}
void main(){
polynomial A = {2, {1, 3, -2}};
polynomial B = {3, {2, 0, 1, 0}};
polynomial C;
C = mult(A,B);
printf(\"\\n A(x)=\");
printpoly(A);
printf(\"\\n B(x)=\");
printpoly(B);
printf(\"\\n C(x)=\");
printpoly(C);
}
1. 프로그램 3.6
#include
void swap(int *px, int *py)
{
int tmp;
tmp = *px;
*px = *py;
*py = tmp;
}
void main()
{
int a=7;
int b=10;
printf(\"a = %d , b = %d \\n\",a,b);
swap(&a,&b);
printf(\"a = %d , b = %d \\n\",a,b);
}
2. 프로그램 3.7
#include
typedef struct{
int x;
int y;
}PointType;
int get_line_parameter(PointType p1, PointType p2, float *slope, float *yintercept)
{
if( p1.x ==p2.x ) return (-1);
else{*slope = (float)(p2.y - p1.y)/(float)(p2.x - p1.x);
*yintercept = p1.y - (*slope)*p1.x;
return(0);}
}
void main()
{PointType pt1={3,3}, pt2={6,6};
float s,y;
if(get_line_parameter(pt1, pt2, &s, &y) == -1){
printf(\"error\\n\");}
else{printf(\"rldnfrlsms %f, y절편은 %f\\n\",s ,y);
}
}
3. 프로그램 3.8
#include
void main()
{
struct{
int i;
float f;
}s, *ps;
ps = &s;
ps->i = 2;
ps->f = 3.14;
printf(\" %d , %f \\n\", s.i, s.f);
}
4. 프로그램 3.9
#include
void foo(int a)
{
printf(\"foo : %d\\n\", a);
}
void main()
{
void (*f)(int);
f = foo;
f(10);
(*f)(10);
}
}
void main(){
polynomial A = {2, {1, 3, -2}};
polynomial B = {3, {2, 0, 1, 0}};
polynomial C;
C = mult(A,B);
printf(\"\\n A(x)=\");
printpoly(A);
printf(\"\\n B(x)=\");
printpoly(B);
printf(\"\\n C(x)=\");
printpoly(C);
}
1. 프로그램 3.6
#include
void swap(int *px, int *py)
{
int tmp;
tmp = *px;
*px = *py;
*py = tmp;
}
void main()
{
int a=7;
int b=10;
printf(\"a = %d , b = %d \\n\",a,b);
swap(&a,&b);
printf(\"a = %d , b = %d \\n\",a,b);
}
2. 프로그램 3.7
#include
typedef struct{
int x;
int y;
}PointType;
int get_line_parameter(PointType p1, PointType p2, float *slope, float *yintercept)
{
if( p1.x ==p2.x ) return (-1);
else{*slope = (float)(p2.y - p1.y)/(float)(p2.x - p1.x);
*yintercept = p1.y - (*slope)*p1.x;
return(0);}
}
void main()
{PointType pt1={3,3}, pt2={6,6};
float s,y;
if(get_line_parameter(pt1, pt2, &s, &y) == -1){
printf(\"error\\n\");}
else{printf(\"rldnfrlsms %f, y절편은 %f\\n\",s ,y);
}
}
3. 프로그램 3.8
#include
void main()
{
struct{
int i;
float f;
}s, *ps;
ps = &s;
ps->i = 2;
ps->f = 3.14;
printf(\" %d , %f \\n\", s.i, s.f);
}
4. 프로그램 3.9
#include
void foo(int a)
{
printf(\"foo : %d\\n\", a);
}
void main()
{
void (*f)(int);
f = foo;
f(10);
(*f)(10);
}
소개글