Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <stdlib.h>
- typedef struct _node {
- float data;
- struct _node *next, *prev;
- } node;
- node *addNode(node **head, node *tail, float num)
- {
- node * n = (node*) malloc(sizeof(node));
- n->next = NULL;
- n->prev = tail;
- n->data = num;
- if (tail)
- {
- tail->next = n;
- }
- tail = n;
- if (!*head) *head = tail;
- return tail;
- }
- int main(){
- node *i, *j;
- float out = 1.0, t = 1.0;
- node *head = NULL;
- node *tail = NULL;
- while (1)
- {
- scanf("%f", &t);
- if (t == .0) break;
- tail = addNode(&head, tail, t);
- }
- i = head;
- j = tail;
- while (i && j)
- {
- out *= i->data - j->data;
- printf("%.3f ", i->data);
- i = i->next;
- j = j->prev;
- }
- printf("\n%.3f\n", out);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment