void main () { Q = QCreate (); long double i; int n; long double x; long double y; Point Points[1000]; printf("\nExample 1 from Div Diff\n\n"); Points[0].x = 1; Points[0].y = 0.7651977; Points[1].x = 1.3; Points[1].y = 0.620086; Points[2].x = 1.6; Points[2].y = 0.4554022; Points[3].x = 1.9; Points[3].y = 0.2818186; Points[4].x = 2.2; Points[4].y = 0.1103623; n = 5; x = 1.5; y = FindDivDiff (n, Points, x); printf ("\nSolution for %Lf with %d points is %30.20Lf\n", x, n/2, y); printf("\nHomework Problem 1a from Div Diff\n\n"); Points[0].x = 8.1; Points[0].y = 16.94410; Points[1].x = 8.3; Points[1].y = 17.56492; Points[2].x = 8.6; Points[2].y = 18.50515; Points[3].x = 8.7; Points[3].y = 18.82091; n=4; x=8.4; y = FindDivDiff (n, Points, x); printf ("\nSolution for %Lf with %d points is %30.20Lf\n", x, n/2, y); printf("\nHomework Problem 1b from Div Diff\n\n"); Points[0].x = 0.6; Points[0].y = -0.17694460; Points[1].x = 0.7; Points[1].y = 0.01375227; Points[2].x = 0.8; Points[2].y = 0.22363362; Points[3].x = 1.0; Points[3].y = 0.65809197; n=4; x=.9; y = FindDivDiff (n, Points, x); printf ("\nSolution for %Lf with %d points is %30.20Lf\n", x, n/2, y); printf("\nHomework Problem d from Div Diff\n\n"); Points[0].x = 1960; Points[0].y = 179323; Points[1].x = 1970; Points[1].y = 203302; Points[2].x = 1980; Points[2].y = 226542; Points[3].x = 1990; Points[3].y = 249633; Points[4].x = 2000; Points[4].y = 281442; Points[5].x = 2010; Points[5].y = 307746; n=6; x=2005; y = FindDivDiff (n, Points, x); printf ("\nSolution for %Lf with %d points is %30.20Lf\n", x, n/2, y); }
void main () { Q = QCreate (); long double i; int n = 6; long double x; long double y; Point Points[1000]; Points[0].x = 1.3; Points[0].y = 0.6200860; Points[0].dif = -0.5220232; Points[1].x = 1.3; Points[1].y = 0.6200860; Points[1].dif = -0.5220232; Points[2].x = 1.6; Points[2].y = 0.4554022; Points[2].dif = -0.5698959; Points[3].x = 1.6; Points[3].y = 0.4554022; Points[3].dif = -0.5698959; Points[4].x = 1.9; Points[4].y = 0.2818186; Points[4].dif = -0.5811571; Points[5].x = 1.9; Points[5].y = 0.2818186; Points[5].dif = -0.5811571; /* if (n == 0) for (n = 0, i = 2; i < 4; i = i + .03001, n++) { Points[n].x = i; Points[n].y = 1/i ; } */ x = 1.5; y = FindHermite (n, Points, x); printf ("\nSolution for %Lf with %d points is %30.20Lf\n", x, n/2, y); Points[0].x = 0; Points[0].y = 0; Points[0].dif = 75; Points[1].x = 0; Points[1].y = 0; Points[1].dif = 75; Points[2].x = 3; Points[2].y = 225; Points[2].dif = 77; Points[3].x = 3; Points[3].y = 225; Points[3].dif = 77; Points[4].x = 5; Points[4].y = 383; Points[4].dif = 80; Points[5].x = 5; Points[5].y = 383; Points[5].dif = 80; Points[6].x = 8; Points[6].y = 623; Points[6].dif = 74; Points[7].x = 8; Points[7].y = 623; Points[7].dif = 74; Points[8].x = 13; Points[8].y = 993; Points[8].dif = 72; Points[9].x = 13; Points[9].y = 993; Points[9].dif = 72; n = 10; // 55mph is 80.6667 feet per second long double prev = 0; //long double step = .0001; long double step = 1; printf ("\nSolution\ttime\tdistance\tdist per unit\tspeed\n"); //for (i=0; i< (13+step); i = i + step) { for (i=10; i< (10+step); i = i + step) { y = FindHermite (n, Points, i); printf ("\nSolution\t%Lf\t%30.20Lf\t%Lf\t%Lf\n", i, y, (y-prev), (y-prev)*(1/step)*3600/5280); prev = y; } }
int main(int argc, char **argv){ List list = LLCreate(); Stack stack = SCreate(); Queue queue = QCreate(); User *usr; setupUsers(); MENU_CHOICE m_choice = MAIN_MENU; int choice, count; menu(); choice = getChoice(); while(choice){ switch(m_choice){ case MAIN_MENU: switch(choice){ case 1: m_choice = LL_MENU; llmenu(); break; case 2: m_choice = QUEUE_MENU; qmenu(); break; case 3: m_choice = STACK_MENU; smenu(); break; case 4: showUsers(); menu(); break; case 0: exit(0); break; default: m_choice = MAIN_MENU; menu(); } break; case LL_MENU: switch(choice){ case 1: printf("\n%s\n", "adding head, choose a user"); usr = chooseUser(); printf("%s %s\n", "You chose ", usr -> name); LLAddHead(usr, list); llmenu(); break; case 2: printf("\n%s\n", "adding tail, choose a user"); usr = chooseUser(); printf("%s %s\n", "You chose", usr -> name); LLAddTail(usr, list); llmenu(); break; case 3: printf("\n%s\n", "removing head"); LLRemoveHead(list); llmenu(); break; case 4: printf("\n%s\n", "removing tail"); LLRemoveTail(list); llmenu(); break; case 5: print(list); llmenu(); break; case 6: m_choice = MAIN_MENU; menu(); break; case 0: exit(0); break; default: m_choice = LL_MENU; } break; case QUEUE_MENU: switch(choice){ case 1: printf("\n%s\n", "enqueueing, choose a user"); usr = chooseUser(); printf("%s %s\n", "You chose ", usr -> name); Qenqueue(usr, queue); qmenu(); break; case 2: printf("\n%s\n", "dequeueing"); Qdequeue(queue); qmenu(); break; case 3: print(queue); qmenu(); break; case 4: m_choice = MAIN_MENU; menu(); break; case 0: exit(0); break; default: m_choice = QUEUE_MENU; } break; case STACK_MENU: switch(choice){ case 1: printf("%s\n", "push"); smenu(); break; case 2: printf("%s\n", "pop"); smenu(); break; case 3: printf("%s\n", "top"); smenu(); break; case 4: printf("%s\n", "print"); smenu(); break; case 5: m_choice = MAIN_MENU; menu(); break; case 0: exit(0); break; default: m_choice = STACK_MENU; } break; } choice = getChoice(); } return 0; }