Read about c code | 6 Discussions | Page 1

  1. A

    Comp Sci Huffman Tree Coding

    First, I get the string and I find the frequency of the every character. My struct is: typedef struct huffman_tree{ char c; int freq; //unsigned? struct huffman_tree *left; // 0 (left) struct huffman_tree *right; // 1 (right) }huffman_tree; I write this to create Huffman tree...
  2. A

    Comp Sci String and sscanf

    #include<stdio.h> int main(){ char str[]="My first book"; char *a,*b,*c; sscanf("%s %s %s",a,b,c); printf("a=%s b=%s c=%s",a,b,c); } I want the output: a= My b=first and c=book. But it does not work, why?
  3. A

    Recursively calculate the standard deviation

    #include<stdio.h> #include<math.h> double foo(int n, int mean){ double square; if(n==1){ return(1); } if(n!=0){ square=pow(n-mean,2); return( (sqrt(square)+foo(n-1,mean))/(sqrt(n-1)) ); } } int main(){ int num; double mean; int i...
  4. A

    Comp Sci Calculating a math formula using void function-recursion in C

    how can i write a function that calculate math formula using void function-recursion in C?
  5. A

    Comp Sci Do-while loop-> exit not working (making a crossword puzzle)

    Hello! My homework is making a crossword. I write a code like this: do{ //code printf("Please enter the coordinate and the word: \n"); scanf(" %c%d %s",&row2,&column2,word2); if(row2=='E' && word2=="xit") exit(0); //code }while(count2!=10); But this is...
  6. V

    Why does not this Erdos-Renyi C code work?

    Homework Statement I need to write an Erdos-Renyi random graph, by using the adjacency matrix (or alternatively list) and calculate the fitness of the graph. Definition: G(n, p) is a random graph with n vertices where each possible edge has probability p of existing. Homework Equations The...
Top