Search results

  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 Using Malloc to Read a File Dynamically

    #include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> #include<time.h> int main(){ int index=1; int *arr; int data; char *c; FILE *fp; int input,inp; arr=(int*)malloc(sizeof(int)); fp=fopen("list2.txt","r")...
  3. 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?
  4. A

    C/++/# Recursive-Array

    I want to write code walk around the array recursively. For some reason I cannot share my code. Let's say I have a array like this: arr[4], I want to look 012 123 013 or 01 12 23 02 03 13. In code I write I can look 012 123 or 01 12 23 but I cannot look 013 or 02 03 13. What algorithm should I...
  5. A

    Comp Sci Using Recursion to Calculate (n + r)!/(n! * r!)

    I wirte code but it does not work. I entered n=5 and r=2, result is 0. And I want to calculate this recursively. #include<stdio.h> int func(int n, int r); int main(){ int n,r; int result=0; printf("Enter the number:\n"); scanf("%d",&n); printf("Enter the 2.number:\n")...
  6. 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...
  7. A

    Comp Sci Recursive Double code to Calculate the sum of the square roots <= a number

    #include<stdio.h> #include<math.h> double foo(int n){ if(n==1){ return(1); } if(n!=0){ return( sqrt((n)+foo(n-1) ) ); } } int main(){ int num; printf("Enter the number: "); scanf("%d",&num); foo(num); printf(" %lf ",foo(num)); return(0)...
  8. A

    Comp Sci Recursion double function

    double foo(int arr[], double *ave, int index){ double *s; *s=*ave; // calculation// return(foo (arr,ave,index)); // other calculation// } I want to keep the ave value during the recursion, because after ave is calculated, I will do another calculation is recursively in this...
  9. 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...
Top