- Upvotes Received
- 1
- Posts with Upvotes
- 1
- Upvoting Members
- 1
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
37 Posted Topics
I need help with the following program: Create linear representation of stack with size N. Stack contains N binary search trees with serial number of the position on the stack from 1 to N and with the minimum p and maximum q nodes in a tree. Values p and q … | |
I have problems with the following program which is long to post at once so I will explain what are the problems step by step. 1. Define two structs that represents books and a bookstore as following: typedef struct { char id[14]; char title[16]; int availableNumOfBooksWithSameTitle; }BOOK; typedef struct { … | |
Write a program that will print all highly prime numbers from the input interval <a,b>. Prime number is highly prime if deletion of every digit from right is a prime. Example: 239 is highly prime because 239,23,2 are primes. Could someone point out what are logic errors in the following … | |
Create doubly linked list that has the following information about **books**: **book_id, book_name, author_id, book_price**. Sort list in ascending order by **book_price** using bubble sort algorithm. Delete all books with the smallest and the largest price. How to modify the following program such that the sorting is done using bubble … | |
Assume that a file exists. How to replace the occurrence of a character with another character? | |
Write a program that will print two closest pair integers in an array (if there are more than one pair with the same distance, then print all pairs). //Example: 6 -3 8 0 5 //The closest numbers: 5 6 -> difference is 1 In the following program I am using … | |
I don't understand how to debug the following code "on paper" (without a compiler): #include <stdio.h> #define SUB(T,x,y) {T x=y++; {T x=y++;}} int x; static int y; void f(int n) { if (n) { SUB(int,x,y) f(n-1); } } main() { extern int x,y; int i=0; for ( ; ++i<3; ) … | |
Write a program that will print adjacency matrix of a directed and weighted graph. Weights are positive real values, and graph is strongly connected. Then, print values of two vertices which indices are read (values of each vertice are functions: **sin(index),cos(index),index^2,sqrt(index)**). How to check if a graph is strongly connected? … | |
I need some explanation with the logic in the following program: Create a data structure such that it contains of three singly linked lists that are connected to one central node. **i-th** list can only have elements such that **list_element % 3 = i**. First element of every list represents … | |
Write a program that will read data about **n** movies (data about a movie is defined in structure). Sort data about movies (criteria of sorting is by title of a movie and by surname and name of an actor). Read data about one actor, and print data about all movies … | |
Write a program that reads **n** strings (with blank spaces). For each read string, check if it is a permutation of some other read string. If it is, print the found string and all other found strings that are permutations of the found string. Uppercase and lowercase letter are not … | |
Write a program that reads an array of **n** polynomials and prints their squares using arrays. Example input: n=1 1. polynomial: order: 2 coefficients: 1 1 1 Output: square(x^2+x+1)=2x^3+4x^2+2x+1 The following code gives **SIGSEGV** segmentation fault: #include <stdio.h> #include <stdlib.h> #define MAX_ORDER 10 typedef struct term { int coef; int … | |
I am having problems to figure out how to do arithmetic operations on positive integers represented as strings (addition, subtraction, multiplication, incrementing and decrementing). I did the addition as following: #include<stdio.h> #define MAX 100000 typedef struct { int arr[MAX]; }NUMBER; void read(NUMBER *add_num) { int i,digit=0; char ch[101]; scanf("%s",ch); while(ch[digit]) … | |
I need help with the following program: Define a structure **VEHICLE** which contains **producer, model and chassis number**. Store the content of a structure in binary search tree such that the **key** for storing contains all fields of a structure (**producer** has the highest priority, and **chassis number** has the … | |
The following program should create singly cyclic linked list which has **n** nodes, where data are random generated numbers from **0-99**. Create binary search tree which will contain all prime numbers from the list. Print binary tree in text file so that numbers are sorted in descending order and every … | |
The following program compiles successfully but doesn't give the output: Write a program that reads data about **n** number of **books**. Sort data about books lexicographically by **title** (if the title is the same, sort by **publish year**), and then for every book sort data about **authors**. Then, read **name** … | |
I need help with the following program: Create a structure **STRING** which represents a string ( as singly linked list). Check if the string is a palindrome using stack and function which prototype is **int palindrome(STRING *str);** Code: #include <stdio.h> #include <stdlib.h> typedef struct { char *info; }STRING; typedef struct … | |
Write a function for swapping players in a team. New player (which is read) enters team and replacing the player which is also read. Prototype of function is void swap(TEAM *, PLAYER, int); First argument of a function is the pointer to team, second argument is the player that enters … | |
Write a program that reads data from binary file **EMPLOYEE.DAT** (employees are proffesors and teaching assistants, assume that the file exists). Split data about proffesors and teaching assistants in two separate text files and sort data by **ID** using insertion sort algorithm. Search and print data about employee which **ID** … | |
Write an iterative function **char* conversion(unsigned int num, int base)**, that converts an integer **num** into any **base** **(base <=10)**. How to transform the following recursive function conversion() into iterative: #include <stdio.h> void conversion(unsigned num, unsigned base) { if (num / base) conversion(num / base, base); printf("%u", num % base); … | |
Write a program that reads strings(words) from a text file and copy the inverted words to another file (use the command line arguments). Form a new array of words b from original array a using the function ***void formNewArray(char **a, char **b, int n, char* (*t)(char *));*** where ***n*** is … | |
I am having a problem when trying to delete specific record from a text file. Data structure is as follows: typedef struct { char id[9]; char name[50]; float amount,price; }PRODUCT; typedef struct id { char key[9]; int address; }ID;//for searching typedef struct node { ID id; struct node *left,*right; }NODE; … | |
What books would you recommend for data structures and algorithms in C language? It would be good if recommended books are books of solved problems. | |
I have a matrix structure (for storing squared matrices) which is defined as typedef struct { int **matrix; int format; }MATRIX; How to add 'n' number of matrices? | |
How to print path of a binary tree after adding every node (branches of a tree have values 0 and 1)? For example, I have this binary tree: NODE1 has two children, NODE2 and NODE3. Branch from NODE1 to NODE2 is 0, and from NODE1 to NODE3 is 1. From … | |
Hi. I need help with the following C program: How to print first member of sequence so that condition `|a(n)-a(n-1)|<EPS` is true, where *EPS* is a random input precision (double value). Sequence *a(n)* is given by: `a(n)=(1-1/2!)(1+1/3!)...(1+(1/(n+1)!))` I tried to cancel factorial in the expression `a(n)-a(n-1)=((-1)^n(n+2))/(n+1)!`, but I don't know … | |
How to access each element of array of words? For example, if I want to find number of vowels in every word of an array. #include<stdio.h> #include<stdlib.h> int main() { int i,n; char **array; do { printf("n=");scanf("%d",&n); } while(n<1); array=(char **)malloc(n * sizeof(char *)); Thanks for replies. | |
How to concat multiple strings in C? I have a function for concat two strings: char* concat(char *s1, char *s2) { char *r, *t; int d1 = -1, d2 = -1; while (s1[++d1]); while (s2[++d2]); t = r = (char *)calloc(d1 + d2 + 1, sizeof(char)); while (*t++ = *s1++); … | |
I have a C code written in Visual C++ 2010 environment and it compiles without errors. When I try to debug it, after the line with scanf() function it goes to unknown scope and stops the process of debugging. How to fix this? Thanks for replies. | |
Which tool for code analysis is the best for complex C programs? I use GCC debugger with Code Blocks 13.12 Thanks for replies. | |
I need help with recursion function. It prints all the prime factors of an input number. My question is how to modify function so that START-GOTO is replaced by a loop? Here is the code: int f(int n,int i) { start: if(n==1) goto start; if(n % i == 0) { … | |
Hi. I need help with this program: Example input: 2 4 6 -1 7 3 -2 1 Output: 3 3 (longest series of even is 3, longest series of positive is 3) Here is the code: #include <stdio.h> int even(int x) { return x % 2 == 0; } int … | |
I need to create dynamic string by given format(%d,%s,%f,%lf,%c) using variable number of arguments in function. This code gives me an error(main.exe has stopped working): #include<stdio.h> #include<stdarg.h> #include<string.h> #include<stdlib.h> char *form(char *format,...); char *form(char *format,...) { char *res=(char *)calloc(1,1),val_int[12],*pos_int,*val_str,*pos_str,*val_float,*pos_float,*val_lf,*pos_lf,*val_char,*pos_char; va_list args; va_start(args,format); do { pos_int=strstr(format,"%d");pos_str=strstr(format,"%s");pos_float=strstr(format,"%f");pos_lf=strstr(format,"%lf");pos_char=strstr(format,"%c"); if(pos_int && (!pos_str || pos_int … | |
Can someone explain this code step by step: #include <stdio.h> #define MAX 10 int main() { char niz[MAX][MAX], c = 0; int d = 1, x = 0, i, j; do scanf("%s", niz[x]); while (niz[x++][0] != '0'); { float* pf; int xx, *pi = (int*)&niz[0][7]; xx = ((*pi) & 0x41000000); … | |
Hi. I have a question about one function in my program. Write a function that will replace players in a tim. New player gets in the game, and takes the place of one that leaves. Prototype of function is: void replace(TEAM *p,PLAYER newplayer,int num) where second parameter is new player, … ![]() | |
Hi. How to find index of first letter in every word in a string? For example, input string is: Programming Languages. Output should be: 0 12, those are the indexes of letters "P" and "L". I tried different approach, to print those numbers but that didn work. Thanks for the … | |
Hi. I need help finding the longest word in a string. How to return last longest word if there are two or more words with the same (longest) length? My code: #include <stdio.h> #include <string.h> int main() { char string[100], word[20], max[20], min[20], c; int i = 0, j = … |
The End.