#include <stdio.h>
#include <math.h>
#define MAX_DEGREE 10
/*to do here
1.manipulate the pointer
2.use of pow
3.saving polynomial in two dimentional array 8x의3승 + 7x의 1승 + 1
4.saving polynomial in struct
5.using define
*/
typedef struct {
int coef[3];
int expon[3];
}polyStruct;
int main()
{
//1.
printf("1. manipulate the pointer \n");
int toBePointed = 2;
int* ptr = &toBePointed;
printf("Addr of toBePointed : %d, value : %p\n", ptr, *ptr);
//??why zeros are printed??
//2.
printf("\n2.use of pow \n");
int base = 2;
int power = 6;
int result = pow(base, power);
printf("2 power 6 is %d\n", result);
//3.
printf("\n3.saving polynomial in two dimentional array 8x의3승 + 7x의 1승 + 1\n");
int degree = 4;//최고차항
int poly[degree] = {8,0,7,1};
for(int i = 0; i<degree; i++)
{
printf("%dx %d승\n", poly[(i)], 4-i);
}
//4.
printf("\n4.saving polynomial in struct \n");
polyStruct polyStruct1;
polyStruct1.coef[0] = 8;
polyStruct1.coef[1] = 7;
polyStruct1.coef[2] = 1;
polyStruct1.expon[0] = 3;
polyStruct1.expon[1] = 1;
polyStruct1.expon[2] = 0;
for(int i = 0; i<=2; i++)
{
printf("%dx %d승\n", polyStruct1.coef[i], polyStruct1.expon[i]);
}
return 0;
};
/* soso very great to back to school, far better than part time job...everythiing is much interesting!!!!
plus i forgot a lot of coding heeh.....
*/
댓글
댓글 쓰기