Beispiel #1
0
void post_display(unsigned long number)
{
   	char mode = read_adc_mode();

	if(1==mode){//50R, divid 32
	
		number*=32;
	}
	lcd_cursor(0,0);
    
	if((number>999)&&(number<999999)){
	   printLL(number,3,3);
	   lcd_puts("KH");
 	}

    if(number>999999){
	   printLL(number,6,6); //omit xxHz
	   lcd_puts("MH");
   	
	}
	if(number<=999)
	{
	
	   printLL(number,0,0);
	   lcd_puts("Hz");

	}
  	lcd_puts("       ");
	lcd_puts("    ");
}
Beispiel #2
0
	static void
do_arc(void) {
	double az;

	printLL(phi2, lam2); putchar('\n');
	for (az = al12; n_alpha--; ) {
		al12 = az = adjlon(az + del_alpha);
		geod_prefor();
		geod_forwd();
		printLL(phi2, lam2); putchar('\n');
	}
}
Beispiel #3
0
int main (int argc, char *argv){
	int values[] = {1,2,3,4,5,6,7,8,9,10};
	lnode *head = (lnode *) malloc(sizeof(lnode));
	makeLL(&head,values);
	printLL(&head);
	insertLL(&head,23,4);
	printf("after inserting	 \n");
	printLL(&head);
	deleteLL(&head,4);
	printf("after deleting \n");
	printLL(&head);
	return 0;
}
Beispiel #4
0
	static void	/* generate intermediate geodesic coordinates */
do_geod(void) {
	double phil, laml, del_S;

	phil = phi2;
	laml = lam2;
	printLL(phi1, lam1); putchar('\n');
	for ( S = del_S = S / n_S; --n_S; S += del_S) {
		geod_forwd();
		printLL(phi2, lam2); putchar('\n');
	}
	printLL(phil, laml); putchar('\n');
}
Beispiel #5
0
Datei: main.c Projekt: quano1/FS
int main()
{
    srand(time(NULL));

    unsigned char arrCharDevice[MAX_DEVICE][DEVICE_SIZE];
    unsigned char chDevice[] = {0xb,0x0,'F','S','o','f','\0',0x0,0x1,0x0,0x0};
    int i,j;
    device **ppd;
    device *tmp;

    linkedlist ll;
    initializeLL(&ll);  //initialize linkedlist
    initArrayDeviceData(arrCharDevice, MAX_DEVICE, DEVICE_SIZE);    //create data array of device
    ppd = initArrayDevice(arrCharDevice, MAX_DEVICE, DEVICE_SIZE);  //create array of device

    for(i=0; i<MAX_DEVICE; i++) {
        printDevice(*(ppd+i));
        addFirst(&ll, *(ppd+i));    //insert device into linkedlist
    }

    FL; printLL(&ll);

    tmp = (device*)chDevice;
    FL;printDevice(tmp);

    insertElement(&ll, tmp, 5);            //insert above device into linkedlist
    FL;printLL(&ll);

    rmElement(&ll,4);                       //remove element from linkedlist
    FL;printLL(&ll);

    free(tmp);
    freeLL(&ll);
    freeArrayDevice(&ppd, MAX_DEVICE);

    unsigned short asdf = 0xF0AA;
    unsigned char *asda = (char*)malloc(sizeof(asdf));

    FL; PRINT_HEX(asdf); EL;
    printf("%X", asdf&0xff); EL;

    convertToChar(asda, &asdf, 0, sizeof(short));

    FL; PRINT_HEX(*asda); SP; PRINT_HEX(*(asda+1)); EL;

    PRINT_UINT(sizeof(aaa)); EL;

    return 0;
}
Beispiel #6
0
int main(){
    node* head = NULL;
    head = add(head, 1);
    head = add(head, 2);
    head = add(head, 3);
    head = add(head, 4);
    head = add(head, 5);
    //head = reallocReverse(head);
    printLL(head);
    head = reverse(head);
    // node* temp = head->next;
    // head->next = NULL;
    // temp->next = head;
    // head = temp;
    printLL(head);
    return 0;
}
Beispiel #7
0
int main() {
    struct node *head;
    /* creating List
    
    10-->2-->5-->7-->NULL 
    
    */
    struct node *start = newnode(10);
    start->next = newnode(2);
    start->next->next = newnode(5);
    start->next->next->next = newnode(7);
    printLL(start); 
    head = start;
    InsertNode(&start,15);
    printLL(start);
   
}
Beispiel #8
0
int main(){

    addToFront(6);
    addToFront(5);
    addToFront(4);
    addToFront(3);
    addToFront(2);
    addToFront(1);

    printLL(gHead);

    gHead = oddEvenList(gHead);

    printLL(gHead);

    return 0;
}
int main(){
  int i=0;
  struct LinkedList* L = (struct LinkedList *)malloc(sizeof(struct LinkedList));
  for(i=0; i< 28; i++)
   {
     if(i%5 ==1)
      addLL(i,L);
   }
  printLL(L);
  printf("Test delete head\n");
  L= deleteLL(0, L);
  printLL(L);

  printf("Test delete middle\n");
  L = deleteLL(16, L);
  printLL(L);
  return 0;
}
Beispiel #10
0
void testLL() {
    node* head = NULL;
    int vals[20] = {2,2,2,4,4,2,6,2,4,4,31,37,9,6,4,5,2,2,2,4};
    // Initialize:
    int i;
    for (i=0; i < 20; i++) {
        insertNode(&head, vals[i]);
    }
    
    // Get stats
    printf("Size: %d, Index of 6: %d\n", countNodes(head), searchLL(head, 6));
    printLL(head);
    removeNode(&head, 2);
    printLL(head);
    removeNode(&head, 4);
    printLL(head);
    printf("Size: %d, Index of 6: %d\n", countNodes(head), searchLL(head, 6));
}
int main() {
  int arr[10] = {96, 7, 64, 50, 53, 89, 54, 6, 60, 99};
  int len = 9, i = 0;

  // initializing an empty LL
  struct node *root = NULL;

  for (i = 0; i < len; i++) {
    insert(&root, arr[i]);
  }
  printf("original list:\n");
  printLL(root);

  for (i = 0; i < 12; i++) {
    printf("%d\n", i);
    printLL(root);
    swapNodes(&root, i);
    printLL(root);
    printf("\n\n");
  }
}
Beispiel #12
0
int main()
{
    Node *node1 = createNode(4);
    Node *node2 = createNode(3);
    Node *node3 = createNode(4);
    Node *node4 = createNode(5);
    Node *node5 = createNode(5);
    node1->next = node2;
    node2->next = node3;
    node3->next = node4;
    node4->next = node5;
    printLL(removeDups(node1));

    return 0;
}
Beispiel #13
0
int main(){

    std::array<int, TREE_SIZE> valueArray;
    
    for(int i = 0; i< valueArray.size(); i++)
    {
        valueArray[i] = i;
    }

    Node* rootNode = buildTree(valueArray, 0, TREE_SIZE - 1);


    // printTree(rootNode);
    // std::cout << std::endl << std::endl;
    printPathTo(rootNode, &valueArray[7]);
    std::cout << std::endl;

    std::vector<LinkedList*> lists;

    bool unbalance = 0;

    int extra1 = 10;
    int extra2 = 11;

    if(unbalance)
    {
        Node* extraN1 = new Node();
        extraN1->setValue(&extra1);
        Node* extraN2 = new Node();
        extraN2->setValue(&extra2);
        extraN1->setRight(extraN2);
        rootNode->getRight()->getRight()->getRight()->setRight(extraN1);

    }

    getLayers(lists, rootNode, 0);

    for(int i = 0; i < lists.size(); i++)
    {
        printLL(lists.at(i));
        std::cout << std::endl;
    }

    std::pair<bool, int> balanceResultPair = isBalanced(rootNode);
    bool balanceResult = balanceResultPair.first;

    std::cout << std::endl << "Balanced? " << balanceResult << " Height: " << balanceResultPair.second << std::endl;
}
Beispiel #14
0
int main(){
	// struct node *ptr1;
	
	ptr = NULL;

	for(int i=1; i<=10; i++){
		struct node *temp = (struct node*)malloc(sizeof(struct node*));
		temp -> value=i;
		temp -> next=NULL;
		insertIntoLL(temp);
	}

	struct node *temp = (struct node*)malloc(sizeof(struct node*));
	temp -> value=4;
	temp -> next=NULL;
	insertIntoLL(temp);

	struct node *temp1 = (struct node*)malloc(sizeof(struct node*));
	temp1 -> value=11;
	temp1 -> next=NULL;
	insertIntoLL(temp1);
	
	
	struct node *runner1, *runner2;
	runner1 = runner2 = ptr;

	while(runner1!=NULL){
		runner2 = runner1->next;
		while(runner2!=NULL){
			if(runner1->value==runner2->value){
				delete1(runner2->value);
				runner2=runner2->next;
			}
			runner2=runner2->next;
		}
		runner1=runner1->next;
	}

	printLL();
}
Beispiel #15
0
	void static	/* file processing function */
process(FILE *fid) {
	char line[MAXLINE+3], *s;

	for (;;) {
		++emess_dat.File_line;
		if (!(s = fgets(line, MAXLINE, fid)))
			break;
		if (!strchr(s, '\n')) { /* overlong line */
			int c;
			strcat(s, "\n");
			/* gobble up to newline */
			while ((c = fgetc(fid)) != EOF && c != '\n') ;
		}
		if (*s == tag) {
			fputs(line, stdout);
			continue;
		}
		phi1 = dmstor(s, &s);
		lam1 = dmstor(s, &s);
		if (inverse) {
			phi2 = dmstor(s, &s);
			lam2 = dmstor(s, &s);
			geod_invrs();
		} else {
			al12 = dmstor(s, &s);
			S = strtod(s, &s) * to_meter;
			geod_prefor();
			geod_forwd();
		}
		if (!*s && (s > line)) --s; /* assumed we gobbled \n */
		if (pos_azi) {
			if (al12 < 0.) al12 += TWOPI;
			if (al21 < 0.) al21 += TWOPI;
		}
		if (fullout) {
			printLL(phi1, lam1); TAB;
			printLL(phi2, lam2); TAB;
			if (oform) {
				(void)printf(oform, al12 * RAD_TO_DEG); TAB;
				(void)printf(oform, al21 * RAD_TO_DEG); TAB;
				(void)printf(osform, S * fr_meter);
			}  else {
				(void)fputs(rtodms(pline, al12, 0, 0), stdout); TAB;
				(void)fputs(rtodms(pline, al21, 0, 0), stdout); TAB;
				(void)printf(osform, S * fr_meter);
			}
		} else if (inverse)
			if (oform) {
				(void)printf(oform, al12 * RAD_TO_DEG); TAB;
				(void)printf(oform, al21 * RAD_TO_DEG); TAB;
				(void)printf(osform, S * fr_meter);
			} else {
				(void)fputs(rtodms(pline, al12, 0, 0), stdout); TAB;
				(void)fputs(rtodms(pline, al21, 0, 0), stdout); TAB;
				(void)printf(osform, S * fr_meter);
			}
		else {
			printLL(phi2, lam2); TAB;
			if (oform)
				(void)printf(oform, al21 * RAD_TO_DEG);
			else
				(void)fputs(rtodms(pline, al21, 0, 0), stdout);
		}
		(void)fputs(s, stdout);
	}
}