Search results for query: *

  1. A

    PE (Portable Executable) file reading in C

    I need to read PE file. I need to search word in PE file. Search is required to cover only the sections with the “executable” flag. And I need to specify the section where the word found. How can I do this in C? I hope you can help me. And I cannot use 3rd party libraries. This is my task and...
  2. A

    Lex and Yacc declared type -- Getting an error

    in .y code: %union{ int ival; int *ivals; char id[20]; char *str; bool *b; } %start START %token COMMENT OP_PLUS OP_MINUS OP_DIV OP_MULT OP_OP OP_CP OP_DBLMULT OP_OC OP_CC OP_COMMA KW_AND KW_OR KW_NOT KW_EQUAL KW_LESS KW_NIL KW_LIST KW_APPEND KW_CONCAT KW_SET KW_DEFFUN...
  3. A

    Using UML Diagrams for Extraordinary Situations

    this user will only use this function when something extraordinary situation, and that's how I stated it in the use case diagram. Is it a bad method of stating this way?
  4. A

    Comp Sci JButton in JPanel with gridlayout

    Is it possible to bring it into this shape using the gridlayout? I use empty label to add this empty grid This is my code: import javax.swing.*; import java.awt.*; public class test { public static void main(String[] args) { JFrame frame = new JFrame()...
  5. A

    Comp Sci Template for STL in .h File: Error Fix

    in .h file I write like this: namespace board{ template <class T> class BAdapter : public AbstractB{ public: BAdapter(); BAdapter(int x){ x=6; setSize(x); } virtual void setSize(int receivedSize){...
  6. A

    Engineering Circuit Analysis -- How many independent equations can be written using KCL?

    I think there are 4 essential node. So we can write 3 KCL independent equations.
  7. A

    Comp Sci Learning C++: Fixing Class & Vector Error

    I want to create class1. This class will have a private inner class named class2. I want to assign value to member in class2 at first. And I want to create vector<vector<class2>>vec.
  8. A

    Comp Sci Learning C++: Fixing Class & Vector Error

    I am now learning C ++ and trying to learn class and vector. I'm trying to write code, but I got an error. this is my class and enum class: enum class state: char{ empty='.', filled_with_x='x', filled_with_o='o'}; class class1{ private: class class2{ class2()...
  9. A

    Comp Sci Cin.ignore remove first character

    Before this part, I was getting numbers elsewhere using cin. And I add cin.ignore after that and I deleted cin.ignore before getline and it fixed. I'm just seeing your answer, but thank you anyway.
  10. A

    Comp Sci Cin.ignore remove first character

    if(count%2==0){ //for user 1 cout<<"User 1"<<endl; cout << "Please enter your move: "; cin.ignore(); getline(cin,str); //do something } else if (count%2!=0){ //for user 2 cout<<"User 2"<<endl; cout << "Please enter your move: "; cin.ignore(); getline(cin,str); //do something...
  11. A

    Comp Sci Generate random numbers in C++

    I want to generate random numbers in C++. I do not want to use C library function (`<cstdlib> <ctime> (time.h)` ) and class. So I cannot use `rand()` function in C. I want to generate random integer numbers and I guess I can use `<random>` library in C++11. How can I use this generate random...
  12. A

    Comp Sci Creating Huffman Tree with Coding Frequency

    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...
  13. 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")...
  14. A

    Comp Sci String and sscanf

    #include<stdio.h> int main(){ char str[]="My first book"; char *a,*b,*c; sscanf(str,"%s %s %s",a,b,c); printf("a=%s b=%s c=%s",a,b,c); } If I write like this, I am getting seg fault
  15. 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?
  16. A

    Developing Algorithm to Recursively Walk Array: arr[4] Example

    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...
  17. A

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

    Yes, right. But it doesn't work if I entered 5 and 2 , output-2. But if n-5 and r-5 ->output-21
  18. A

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

    Shouldn't function constantly call itself? Is this still recursion?
  19. A

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

    Okay if n=5 and r=5--> 10!/5!*5! is not equal 5!/0!*5!
  20. A

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

    Yes, you are right. It also doesn't return the true result of the division. For example if 5/6 it returns 0. But I have to write int function.
  21. 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")...
  22. A

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

    Yes I can use loop but my teacher does not allow loop in this homework
  23. A

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

    at first I added another value that holds the number in the function like this; #include<stdio.h> #include<math.h> double foo(int n, double mean, int n2){ if(n==1){ return(1); } if(n!=0){ return( (sqrt((n-mean)*(n-mean))+foo(n-1,mean,n2))/(sqrt(n2-1)) ); }...
  24. 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, double mean){ double square; if(n==1){ return(1); } if(n!=0){ return( (sqrt((n-mean)*(n-mean))+foo(n-1,mean))/(sqrt(n-1)) ); } } int main(){ int num; double mean; int i; int sum=0...
  25. 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...
  26. A

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

    not n, n-1. I typed wrong. Forget it and let's say I want to calculate standard deviation recursively.
  27. A

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

    return( sqrt((n))+foo(n-1) ); I write like this and it works. Now I'm wondering where I would write the (n) if I wanted to calculate it sqrt((5+4+3+2+1)/n) recursively.
  28. A

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

    I tried a lot but it does not happen.. :( Anyway thank you for help.
  29. 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)...
  30. A

    Comp Sci Recursion double function

    I did not understand what you say. the function will call itself about 560 times
  31. 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...
  32. A

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

    Yes, string.h is written my code. I tried to use strcmp. When I used this, I get a segmentation fault.
  33. A

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

    I tried to use strcmp. When I used this, I get a segmentation fault.
  34. A

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

    You are right. I don't use this place too much. Please forgive me for my inexperience. :)
  35. A

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

    Thanks for your answer. I tried, but still it does not work.
  36. 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...
Back
Top