- Upvotes Received
- 0
- Posts with Upvotes
- 0
- Upvoting Members
- 0
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
34 Posted Topics
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'` | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 < … | |
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 = … | |
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 … | |
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] … | |
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 ++ ) … | |
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 … | |
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': … | |
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++ … | |
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. … | |
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 * … | |
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 … | |
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 … | |
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: … | |
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 | |
(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. … | |
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 … | |
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? | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
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 … | |
Hello , I have a List<String> and I want to compare in a loop the elements. For example sth like : for (int i=0;i<theList.size();i++){ while (theList.get(i).equals(theList.get(i+1))) ... } I want to compare the next to the previous entry. Thanks | |
I am trying to implement periodic boundary conditions for 2d lattice. I did: int boundary2d(int xpos,int ypos,int stepx,int stepy){ int x=4,y=4; //grid size int **matrix; //the grid matrix int i=stepx+xpos; int j=stepy+ypos; if (i<0) { do { i+=Nx; }while (i>Nx-1); } if (i>Nx-1) { do{ i-=Nx; }while(i>Nx-1); } if (j<0) … | |
Hello , i am trying to understand how periodic boundary condition works.Of course, i understand what it is and how it works,just i am trying to implement it in c++ and i have some problems.( for now i want to make it work in 1d but i want it for … | |
Hello , i have two tables ,animal ,which has name,familie and weight and table food which has feed. I want to assure that every animal has at least one food. I did this : [CODE]import mysql.connector from database import login_info db=mysql.connector.Connect(**login_info) cursor=db.cursor() data=[('Geo','Elephant',['hay',peanuts']), ('Gerald','Gnu',['leaves','shoots']), ('Leo','Leopard',['meat']) ...................... ] for name,familie,feed in … |
The End.