say if N was 10, the outside loop would run 5 times, and the inside loop would also run 5 times, so would it be O(5N)?
Type: Posts; User: bigparker
say if N was 10, the outside loop would run 5 times, and the inside loop would also run 5 times, so would it be O(5N)?
I have some code snippets in which I have to find the run time using big O notation.
code frag 1:
void E(int array[], int N){
int i, j;
for(i=1; i<N-5; i++){
oh ok...i understand. thanks guys, that helped me out alot...its compiling fine now.
line 21 is at "int main(){}"
line 46 is "void swap(int *, int, int)"
and those are double pointers because I thought since my dynamic array was already a pointer, I needed a pointer to the...
When compiling I get these errors:
sort.c:21error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âintâ
sort.c:46: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before â{â to ...
oh ok i attempted to use this
while((j = fscanf(pfile, "%d", &num)) !=EOF){
data_in[i] = num;
i++;
}
oh ok...I got that straight...it was because I had MAX set to a value greater than the number of integers in my input file...
thanks...that got rid of the seg fault. Do you guys have any idea of why the the program would only print the last value in my input file? its prints 421 repeatedly...
# define MAX 1000...
Not to seem basic, but how do i test to be sure that i dont run past the end of my buffer?
int main(){
printf("Cake");
int data_in[100];
FILE *pfile;
pfile = fopen("input.txt", "r");
int i=0;
int num=0;
do{
int main(){
printf("Cake");
int data_in[100];
FILE *pfile;
pfile = fopen("input.txt", "r");
int i=0;
int k=0;
int num=0;
do{
I have no other function in the program. I broke up all of my declarations and initialized all the variables to zero, but the seg fault is still there...
Can someone help me figure out why I am getting a seg fault at run time...
#include <stdio.h>
#include <stdlib.h>
thanks...i got it this part figured out using the strcpy...it ended up looking like this...
while((i=fscanf(fp,"%10s %i %i %f", name, &lattitude, &longitude,&force))!=EOF){
...
alright its seems to make more sense so I tried this:
/*This reads from the input file, and store the data into the array of structs*/
while((i=fscanf(fp2,"%10s %i %i %f", name, &lattitude,...
yeah...im still having some trouble with this strcpy. I guess I need to do some more reading on how to use it, and then figure how to implement it with the struct...
lol...there was one for a minute, i was trying to figure out how to use strcpy to copy the input to my struct. But im drawing blanks..here is what I have so far...
for(g=0;g<1000; g++){...
oh thx. Is there a different way that we must handle char, and strings? the integers are fine, but when I attempt to store the "char name" with:
...
I want to assign the values that were read in from the input file and store them into the array of structs. If my input was:
Alberto 80 8 42.720000
...
ok...Ive changed it up. But when it comes to copying the scanned values into the structure, I'm having some trouble with the syntax.
int j=0;
while((i=fscanf(fp2,"%10s %i %i %f", &name,...
Hello,
I have started to write a program that uses structs, however I am unsure of how to get the data correctly into the array of structs. This is what I Have so far...
#include <stdio.h>...
thank you guys sooo much!! I appreciate the tough love. It made me dig deeper than I thought I could...My program works fine now...
yes...I assumed if i casted the value as a float then it would give me the numeric values after the decimalpoint . But even with the cast if the mean is 3.5 it prints 3 and if sigma is 1.73 its...
i understand how things work here now. i fixed the things that you guys suggested and im getting values now. no more nan outputs. The only thing now is that even though I have specified that the...
Thanks for all your help. I guess I came to the wrong place. Im new to C and pretty much a novice in programming period. I'm not looking for you guys to write my program for me. I'm simply stating...