Posts
 
Reputation
Joined
Last Seen
0 Reputation Points
0% Quality Score
Upvotes Received
0
Posts with Upvotes
0
Upvoting Members
0
Downvotes Received
1
Posts with Downvotes
1
Downvoting Members
1
0 Endorsements
~18.1K People Reached
Favorite Tags
c++ x 67
c x 63
euler x 14
Member Avatar for glao

I have this tree format. > myapp-> > setup.py > tests -> > test_myapp.py > myapp -> > __init__.py > myapp.py And from test_myapp.py, I am calling: `from myapp import myapp` and when I run` python setup.py test` I am getting `No module named 'myapp'`

Member Avatar for glao
0
285
Member Avatar for glao

Hello , I have this code: #include <iostream> #include <cstdio> #include <cstdlib> using namespace std; void message(int numbers) { cout << "Entry to function #" << numbers << endl; if ( numbers > 0 ) { cout << "This is a recursive function." << endl; message( numbers-1 ); } cout …

Member Avatar for glao
0
486
Member Avatar for glao

Hello , I have this: #include <iostream> #include <cstdio> #include <cstdlib> #include <vector> using namespace std; typedef struct { float x; float y; Point *next; } Point; int main() { Point *thePoints = new Point[2]; thePoints[0].x = 2; thePoints[0].y = 3; thePoints[1].x = 4; thePoints[1].y = 5; (thePoints[0])->next= 11; cout …

Member Avatar for glao
0
434
Member Avatar for glao

Hello , I wanted to ask if for these statements in mongo: collection.find({},{}).toArray(function(err, result) { collection.find({email : req.user.email},{}).toArray(function(err, result) { the equivalents in postgresql are: client.query( "SELECT * FROM theTable ", function(err,result) { client.query( "SELECT * FROM theTable WHERE email = 'req.user.email' ", function(err, result) { result should be automatically …

Member Avatar for glao
0
186
Member Avatar for glao

I wrote this function : function range(start,stop,step) { var array =[]; for ( var i = start; i <= stop; i += step ){ array.push(i); } return array; } var m = range(1,10); console.log("length = " + m.length); And it returns one. Since, range returns an array , should't it …

Member Avatar for glao
0
127
Member Avatar for glao

Hello ,I want to ask how can I succeed an analogous from mongodb to postgresql. app.post('/myjob', function(req, res) { var collection = db.collection('theDB'); collection.insert({ "my_id" : myID, .... }, function (err, mes) { if (err) { res.send("There was an error"); } else { console.log("Ok with ID "+myID); res.send({ "Done!", ID …

0
154
Member Avatar for glao

Hello , I am new to javascript and I have the following code in c : #include <stdio.h> #include <stdlib.h> int main() { int height = 8, width = 8; for ( int i = 0; i < height; i++ ) { for ( int j = 0; j < …

Member Avatar for glao
0
364
Member Avatar for glao

Hello , I want to ask why I am not receiving the same result using either the `if` with `break` inside the while loop ,either the `while( x!=X && y!= Y )`. #include <stdio.h> #include <stdlib.h> int sol( int X, int Y ) { int x = 0, y = …

Member Avatar for glao
0
186
Member Avatar for glao

Hello, I have this code: #include<stdio.h> int q = 10; void fun(int *p){ *p = 15; p = &q; printf("%d ",*p); } int main(){ int r = 30; int *p = &r; fun(p); printf("%d", *p); return 0; } which returns `10 15` I can't understand why it doesn't return `10 …

Member Avatar for glao
0
227
Member Avatar for glao

In order to find the most occurent element I am using: int find( int* arr, int size ) { int count = 0, MostOc; for ( int i = 0; i < size; i++ ) { if ( count == 0 ) { MostOc = arr[i]; } if ( arr[i] …

Member Avatar for glao
0
228
Member Avatar for glao

Hello , I want to compare each element of an array with every other. For example, array[0] with array[1] , with array[2] ... Then , array[1] with array[2],with array[3] ... So , I thought something like this : for ( int i = 0; i < N; i ++ ) …

Member Avatar for tinstaafl
0
492
Member Avatar for glao

Hello , Let's say I have : def mine( a, b ): return a>=b - 1 I can't understand what's going on with the -1. So , if a = 4 , b = 2 , it gives True If the opposite it gives False. As I said I don't …

Member Avatar for glao
0
144
Member Avatar for glao

Hello , I can't understand why this loop doesn't work as I wanted. Why the continue statement isn't executed. I want the code to count **only** the user input which is 1 or 2 and stop when the sum is >=25. i = 0 user = input('Enter '1' or '2': …

Member Avatar for glao
0
147
Member Avatar for glao

Hello , I found this puzzle : typedef struct { int dd[ 5 ]; int tx; } node; node * A = new node[ 10000 ]; for ( int i = 0; i < 100000; i++ ) { for ( int j = 0; j < A[ i ].tx; j++ …

Member Avatar for glao
0
148
Member Avatar for glao

Hello , I want to scan each row and find in each column the max element and the corresponding index. Then , swap this column with the column which belongs to the main diagonal ( if a condition is valid ). Finally , do the same for the rest rows. …

Member Avatar for glao
0
206
Member Avatar for glao

Hello , I wanted to ask why this works? int *p = new int[ 1 ]; for ( int i = 0; i < 5; i++ ) { p[i] = i; } for ( int i = 0; i < 5; i++ ) { p[ i ] = 2 * …

Member Avatar for glao
0
104
Member Avatar for glao

Hello , why am I taking : > > *** glibc detected *** ./run: double free or corruption (out) #include <stdio.h> #include <stdlib.h> void func1(int **A ) { *A = (int*) malloc( 2 * sizeof(int)); for (int i = 0; i < 10; i++){ (*A)[ i ] = i; //printf("\nA …

Member Avatar for glao
0
879
Member Avatar for glao

Hello , I can't figure how to properly measure time execution when I have 2 loops and I want to measure the time for the innermost loop: for (int i = 1; i <= N; i++) { ..... clock_t begin = clock(); for (int j =1; j<= M; j++){ //want …

Member Avatar for Suzie999
0
452
Member Avatar for glao

Hello , I have the following code : int a = 2; int *ptr = &a; int *second = &a + 1; printf("\n ptr = %p\n", ptr); printf("\n second = %p\n", second); which just prints the address of pointers and the address of second is 4bytes next the ptr. Output: …

Member Avatar for glao
0
181
Member Avatar for glao

I am trying this: int test(int **a){ return **a; } int main(){ int p[2]={1,2}; int *a=&p[0]; int **d=&a[0]; //for (int i=0;i<2;i++) // printf("\na=%d\n",a[i]); //ok this works for (int i=0;i<2;i++) printf("\n%d \n",test(&a[i])); return 0; } I want this ` printf("\n%d \n",test(&a[i]));` to work. I want to use a pointer. Thanks

Member Avatar for Banfa
0
207
Member Avatar for glao

(Continued from [here](http://www.daniweb.com/software-development/cpp/threads/474128/column-major-not-shown-right#post2070227) ) I am trying to use column major order to a 2d matrix which I am using as 1d. int N=3,R=2; for (int i=0;i<N;i++){ for (int j=0;j<R;j++){ //printf("\nX[%d]=%d\t",i+j*N,res[i+j*N]); //column major // printf("\nX[%d]=%d\t",i*R+j,res[i*R+j]); //row major } printf("\n"); } but the column major doesn not work as it should. …

Member Avatar for David W
0
435
Member Avatar for glao

I am trying to use column major order to a 2d matrix which I am using as 1d. int N=3,R=2; for (int i=0;i<N;i++){ for (int j=0;j<R;j++){ //printf("\nX[%d]=%d\t",i+j*N,res[i+j*N]); //column major // printf("\nX[%d]=%d\t",i*R+j,res[i*R+j]); //row major } printf("\n"); } but the column major doesn not work as it should. Also,if I want to …

Member Avatar for glao
0
327
Member Avatar for glao

If I want to multiple 2d arrays as 1d how should I do it? I mean ,I have a 2d array and I map it as 1d: for(int i=0;i<rows*cols;i++) A[i]=... I know how to multiply 2 arrays as 2d ,but representing them as 1d?

Member Avatar for glao
0
2K
Member Avatar for glao

I want to pass an array from one cpp file to another. first: void wrapper(float **A,int N){ N=2; printf("Allocating Matrices\n"); *A = (float*)malloc(N*N*sizeof(float)); for(int i = 0; i < N; ++i){ for (int j=0;j<N;j++){ *A[j+i*N] = i; } } for(int i = 0; i < N; ++i) { for (int …

Member Avatar for glao
0
230
Member Avatar for glao

Hello, I wanted to ask. If I define `typedef float mymat3[3];` and then I have a function: void myfunc(float *One_mat_, .... and inside function I do: mymat3 * One_mat=(mymat3 *)One_mat_; while(i<numPoints) { One_mat[i][0] = (One_mat_[++c1]); Does this mean , that I am copying One_mat_ (which I am casting it as …

Member Avatar for glao
0
168
Member Avatar for glao

hello, I want to compare 2 strings.I want to find if a list with characters contains all the letters in a string. If **all** the letters in the string are in the list. For example: > mystring='abc' > mylist=['a','b','c'] must return True > > mystring='abc' > mylist=['a','c','b'] must return True …

Member Avatar for glao
0
503
Member Avatar for glao

Hello, my code works fine when I don't have white spaces but I can't make it work when the string has. I am trying sth like: def lengthR(mystring): count=0 if mystring=='': return 0 while (mystring!='') and (' ' not in mystring): mystring=mystring[0:-1] lengthR(mystring) count+=1 return count but it returns 0 …

Member Avatar for glao
0
179
Member Avatar for glao

Hello , I am trying to implement this function: def getGuessedWord(theword, wordlist): for letter in theword: if letter in wordlist: print letter, else: print '_', For example: theword = 'hi' wordlist = ['e', 'i', 'o', 's'] must return : _i but it returns : _iNone I tried : for letter …

Member Avatar for glao
0
146
Member Avatar for glao

Hello , I have the following code: count = 0 phrase = "hello, world" for iteration in range(5): index = 0 while index < len(phrase): count += 1 index += 1 print "index: " +str(index) print "Iteration " + str(iteration) + "; count is: " + str(count) I can't understand …

Member Avatar for glao
0
263
Member Avatar for glao

Hello , I am trying to solve some problems from the "Computer Simulation Methods" book. It says > > Write a class that solves the nuclear decay problem.Input the decay constant l from the control window.For l=1 and dt=0.01 ,compute the difference between the analytical result and the result of …

Member Avatar for glao
0
627