1. 재귀함수를 이용하여 피보나치 수열 함수 만들기.
#include <stdio.h>
#include <stdlib.h>

int rFib(int n){
    if(n==0) return 0;
    else if(n==1) return 1;
    else return rFib(n-1) + rFib(n-2);
}


int main(){
    int n ;
    scanf("%d", &n);
    printf("%d\n", rFib(n));

    return 0;
}
  1. 다항식 계산 구조체 만들기.
#include <stdio.h>
#include <stdlib.h>
#define MAX_DEGREE 100
typedef struct
{
    int degree ; // 최고차항 차수 기억
    int coef[MAX_DEGREE];
}Poly;
void print(Poly p){
    int i, j;
    for(i=0, j= p.degree; i<p.degree; i++, j-- ){
        printf("%2dx^%d +", p.coef[i], j);
    }
    printf("%2d\n", p.coef[p.degree]);
}
Poly addPoly(Poly A, Poly B){
    Poly C;
    int Apos = 0, Bpos = 0, Cpos = 0;
    int degA = A.degree;
    int degB = B.degree;
    C.degree = (degA >= degB) ? degA : degB;

    while(Apos <= A.degree && Bpos <= B.degree){
        if(degA > degB){
            C.coef[Cpos] = A.coef[Apos];
            Apos ++ ;
            Cpos ++ ;
            degA -- ; 
        } // if
        else if(degA == degB) {
            C.coef[Cpos] = A.coef[Apos] + B.coef[Bpos];
            Apos ++;
            Bpos ++;
            Cpos ++;
            degA --;
            degB --;
        } // else if
        else {
            C.coef[Cpos] = B.coef[Bpos];
            Bpos++; Cpos ++; degB -- ;
        } // else
    } //while
    return C;
}

int main(void){
    Poly a, b, c;
    scanf("%d %d", &a.degree, &b.degree);

    for (int i=0; i<=a.degree; i++)
        scanf("%d", &a.coef[i]);
    for (int i=0; i<=b.degree; i++)
        scanf("%d", &b.coef[i]);

    print(a);
    print(b);
    c= addPoly(a,b);
    printf("=====================================================================\n");
    print(c);

    return 0;
}