tesuji 135 Master Poster

But i would'nt get a sequence,what i need is a sequence,ie a the numbers should not be repeated in my sequence,all numbers must be unique.

Hi kaos,

there isn't a primal emptiness, space on the internet! So ever tried typing in "unique random numbers" at google? Guess how many entries you would have found then. Exactly, about 5,370,000 just within wee 0.21 seconds!

krs,
tesu

tesuji 135 Master Poster

Thanks for the reply. I just figured it out right before you replied. I just simply used mysql_num_fields

Does this really solve your problem? As I have known mysql_num_fields returns number of columns in a particular select but not the number of rows of a given table, does it?

krs,
tesu

tesuji 135 Master Poster

hi still learning,

obviously, by "length" you mean the number of columns of a table. Such information can easily be get by querying the system catalogue/tables of a database, as for MySql it should be similar like this:

select count(COLUMN_NAME) as 'The length of this row is:'
  from INFORMATION_SCHEMA.COLUMNS
     where table_name = 'yourTableName'

Furthermore, ODBC offers a rather standardized method to query system tables independently of a specific database, you may search on msdn.

I hope that helps you.

krs,
tesu

tesuji 135 Master Poster

Wow, I'm really surprised to see AD so boiled up over something like goto.

. . .

Don't hate GOTO. Hate bad programming. And teach newbies the difference.

Hi Duoas
You wrote an absolute great essay on that topic. I deeply appreciate it. Thank you very much.

When studying your small example it gave me a reality check that the wee goto you were using would have really solved a similar problem I had had recently what dealt with how-to-leave a cascade of if's in the middle of some for's when check fails. I set a flag what has to be rechecked when breaking the loops. Indeed, these breaks are already goto's! But with an explicit goto rechecking the flag wouldn't have been necessary anymore.

krs,
tesu

tesuji 135 Master Poster

hi ChickenFox,
here comes my c++ solution similar to yours. It works well and finds all possible 92 solutions of an 8 by 8 board. You may look at check function what easily checks the row and both diagonals of a tentatively placed queen.

int nbs = 0;
    bool check(int board[], int k)
    { for (int i=0; i<k;i++)
      { if ((board[i]==board[k])||((board[i]-board[k])==(k-i))
        || ((board[k]-board[i])==(k-i))) return 0;
      } return 1;}
    void Queens(int nn, int board[], int k=0)
    { if (k==nn)
      { cout<<endl<<"Solution "<<(++nbs)<<":"<<endl;
        for (int i=0; i<nn; i++)
        { for (int j=0; j<nn;j++)
          { if (board[i]==j) cout<<("Q "); else cout<<(". ");
          } cout<<endl;} cout<<endl;}
        else
        { for (int i=0; i<nn; i++)
          { board[k]=i; if (check(board, k)) Queens(nn, board, k+1);
        }}}
    int main(int argc, char *argv[])
    { int nn = 8;
      int *board = new int[nn];
      Queens(nn, board);
      return 0;}

Here some output:

Solution 1:
Q . . . . . . .
. . . . Q . . .
. . . . . . . Q
. . . . . Q . .
. . Q . . . . .
. . . . . . Q .
. Q . . . . . .
. . . Q . . . .

. . .

Solution 92:
. . . . . . . Q
. . . Q . . . .
Q . . . . . . .
. . Q . . . . .
. . . . . Q . .
. Q . . . . . .
. . . . . . Q .
. . . . Q . . .

krs,
tesu

tesuji 135 Master Poster

hi
try this in main():

double volumn;
cout<<(volumn = BoxDimensions(l,w,h,v))<<endl<<endl;
cout<<DisplayData(l,w,h,volumn)<<endl;

btw, you should better "sort" the parameters of both functions.

krs,
tesu

tesuji 135 Master Poster

Hi yap,
replace cin.get() by these

void waitReturn()
{ char c;
cout << "Return to continue...";
//////////////c=cin.get();
cin.read(&c,1);
if (cin.peek() == 0xA) {;}
}
yap

This works fine for gcc programs.

krs,
tesu

tesuji 135 Master Poster

Hi vieestchien

There is also famous Mersenne Twister MTRand by Makoto Matsumoto.

krs,
tesu

tesuji 135 Master Poster

I've not used create table command to create the table.
in SQl server management studio u've an option to create a table by right clicking on the table option u'l be providede with a new table option there i've created.

table UserList

user_id int (Primary key)
f_name varchar(50),
login varchar( I should make this field has unique)
address varchar(250)
email varchar(50)

If table already exists you can try this to make column login unique:

ALTER TABLE UserList ADD CONSTRAINT consName UNIQUE FOR login;

You must have owner-rights or sa / dba to this table. There are also some restrictions which depends on creation details, you obviously don't know. The constraint name consName must be a unique name within your database. If you want to remove such constraints you can write: ALTER TABLE UserList DROP CONSTRAINT consName ;

Further information: http://msdn.microsoft.com/en-us/library/ms190273.aspx

You can't add UNIQUE constraint if column already holds duplicate values.

If you have chance to re-create this table, simple write: create table UserList ( ..., login varchar(50) UNIQUE ...., ...); (but be careful not to lose data!)

krs,
tesu

tesuji 135 Master Poster

hi,

Please tell me what the below mentined code is doing? If i pass String s as my name is "xyz. and " i am writing. what should be the output.

Thanks in advance

void parse(Block<String>& f, String s)
{
        int inquote = 0;
        int nf = 0;
        int start = -1;
        for(int i = 0; i <= length(s); i++){
                if(i == length(s) || (isspace(s[i]) && !inquote) || (s[i] == '"' && inquote)){
                        if(start != -1){
                                nf++;
                                f.reserve(nf);
                                if(inquote && i != length(s))
                                        f[nf-1] = s(start,i-start+1);
                                else
                                        f[nf-1] = s(start,i-start);
                                start = -1;
                                inquote = 0;
                        }
                }
                else if(start == -1){
                        start = i;
                        inquote = (s[i] == '"');
                }
        }
        f.size(nf);
}

Amit

nobody is able to help you amid Block, String, length, isspace, reserve...

tesuji 135 Master Poster

so tesuji can you suggest an algorithm better than FFT for getting large numbers(of the order of 10 power 30 or more)?????????

If I were God first I would create new universe to be able to store quintillion figures of those numbers because Milky Way obviously too small. Then I would install just one quintillion hyper light-speed computers everywhere in that new universe to do multiplication recursively by massive parallel computing. Maybe that will help.

tesuji 135 Master Poster

After creating the table i tried to specify the unique key constraint in sql server 2005 but its asking for the expression. I don't know what to give in that expression. can u please help me out in this.

thanx in advance.

pls post your create-table command and specify what column should be unique.

tesuji 135 Master Poster

if i use the query

SELECT iditem, CONVERT(char(20), dt, 105) FROM planeamento

it works just fine.. but in this case the dt (date) field is not recognised..

SELECT planeamento.iditem, idmodelo, item_planeamento.idproduto, item_planeamento.idpele, cor, ordemfabrico, qtd, CONVERT(char(20), dt, 105) FROM produto INNER JOIN item_planeamento ON produto.idproduto = item_planeamento.idproduto INNER JOIN  planeamento ON item_planeamento.iditem = planeamento.iditem WHERE planeamento.idfabrica = 51 AND alterado = 'FALSE' AND estado = NULL GROUP BY planeamento.iditem, produto.idModelo, item_planeamento.idProduto, item_planeamento.idPele, item_planeamento.cor, item_planeamento.ordemFabrico, item_planeamento.qtd, planeamento.dt

Can anyone see what's wrong?

thanks a lot for your help

Hi Porsch

You are joining various tables. Are you sure that dt exists only in table planeamento? If not, dt must be qualified (as like as in group-by clause: planeamento.dt).

krs,
tesu

tesuji 135 Master Poster

correct error message because all attributes of select clause not being part of an aggregate function must also be listed in group by clause, e.g.
if you have

select x , sum (z) from ... group by x

and you add just another attribute

select x, y, sum(z) from... group by x

would cause an error

you need to write

select x, y, sum(z) from... group by x, y

yet, the following is correct

select x, sum(z), avg(y) from... group by x

because y and z are part of aggregate functions.

krs,
tesu

p.s. It would really be easier to give you better advice, if you post your create-table commands AND the select statement you have got an error.

tesuji 135 Master Poster

Oh, not that large, only 10 power 30 !
Possibly you need something badly better than fft :icon_mrgreen: (n*ld(n))

tesuji 135 Master Poster

Hi 2eXtreme
Try:

select Colour, Make, Model count(*) from cars group by Colour, Make, Model

krs,
tesu

tesuji 135 Master Poster

To search for strings in ascii files there exists the amazing Knuth–Morris–Pratt string searching algorithm. It is faster than anything. Try it, and you will be delighted.

tesuji 135 Master Poster

Hi scapu,

Don't lose heart!

Pick out an algorithm, for example Newton's method seems to be rather comfortable to compute the square root of a given number. This method is also identical to the ancient method of the Babylonian to draw the square root of a given number, it s also called the divide-and-average algorithm. http://www.homeschoolmath.net/teaching/square-root-algorithm.php discuss it. Try to design a c program. No matter whether it is complete, compiles with error, or produces imperfect results you should post your tentative steps. Then we will help you.

P.s. I don't agree with the concept of the latter post. The intention of computing the square root that way is not to do it plain "from scratch" but to learn fundamental concepts of numeric analysis, such as approximation, iteration, recurrence, numerical stability, and finally to get acquainted with famous Newton method.

krs,
tesu

tesuji 135 Master Poster

hi tanha,

standard SQL only allows one object per GRANT command. Possibly MySql also does not allow enumerative objects. If so, you should try

GRANT SELECT ON mysql.db TO 'user'@'localhost' IDENTIFIED BY 'password';
GRANT SELECT ON mysql.user TO 'user'@'localhost' IDENTIFIED BY 'password';

krs,
tesu

tesuji 135 Master Poster

Hi Scottie,

if you don't have further columns: select distinct ip_addr from ...

Sometimes SQL statement with group by ip_addr also works

krs,

tesu

tesuji 135 Master Poster

hi, if you want to draw typical mathematical diagrams, I would suggest c++ interface of gnuplot by Robert. This is great for scientific publications, also able to create TeX code.
krs,
tesu

tesuji 135 Master Poster

Well, then

cout << "natural logarithm (base e) of 7.9454E-18 is " << log(7.9454E-18) 
<< "\ncommon logarithm (base 10) of 7.9454E-18 is " << log10(7.9454E-18);

//natural logarithm (base e) of 7.9454E-18 is -39.3739
//common logarithm (base 10) of 7.9454E-18 is -17.0999

krs,
tesu

tesuji 135 Master Poster

the
if == 1 || 3 means, in plain english, if f is equal to one or three, which it will be, twice. then it should run until it comes across a zero ...

Always true as Salem already stated. Because 3 != false is true, || 3 always evaluates true! You don' t believe that? try if(false||3) cout "???" and if(true||3) cout "???". What do you see? Possibly you want this: if (f==1 || f == 3) ...

tesuji 135 Master Poster

use log10 --> base 10 logarithm, log() is natural logarithm!

tesuji 135 Master Poster

hi Asif,

if you don't like to query system tables, what really differs from database to database, you can use standard ODBC. ODBC has some functions to query system tables information independently from a specific database system. For example these ODBC functions are usually supported by odbc drivers

SQLColumnPrivileges() - Get column privileges
SQLColumns() - Get column information
SQLForeignKeys() - Get a list of foreign key columns
SQLPrimaryKeys() - Get primary key columns of a table
SQLProcedureColumns() - Get procedure input/output parameter information
SQLProcedures() - Get a list of procedure names
SQLSpecialColumns() - Get special (row identifier) columns
SQLStatistics() - Get index and statistics information for a base table
SQLTablePrivileges() - Get table privileges
SQLTables() - Get table information


You may search the net, for example MSDN-ODBC, IBM-ODBC etc.


krs,
tesu

tesuji 135 Master Poster

Hi tesu,
Thanks for the replies.I have understood what u have said and added a column named level
to get the level of category.
CAT_ID
CAT_NAME
CAT_DESC
CAT_LEVEL
PARENT_CAT
and its working great.

Just out of curiosity, please post the CREATE TABLE statement of your categories tree.

krs,
tesu

tesuji 135 Master Poster
----  Line 13 of previous code listing:

SELECT n, 'Total ', 'counts', sum(st) FROM subtotals

----  must be changed to:

SELECT n, 'Total ', 'counts', sum(st) FROM subtotals group by n

krs,
tesu

tesuji 135 Master Poster

This is what I came up with. Still can't get it to run.

. . .
void binaryAdd( int* sum, int&cBit, const int* bin1, const int* bin2 )
{
       cBit = 0;
       int r;

       for ( int i = 0; i < 8; i++ )
       {
               r = bin1[i] + bin2[i] + cBit;
               if ( r % 2 == 0 ) sum[i] = 0;
               else sum[i] = 1;

               if ( r < 2 )
                       cBit = 0;

               else
                       cBit = 1;
       }
}

Possibly, you don't know what you should change in your function to get it function correctly. These are your problems in binaryAdd of posting #7:

1. Serious problem (where you begin when you are doing addition manually, left or right side?):
for ( int i = 0; i < 8; i++ ) --> for ( int i = 7; i >=0; i-- ) // see posting #9

2. better, for allowing continuous additions:
cBit = 0 --> should be set in main()

3. more beautiful:
if ( r % 2 == 0 ) sum = 0;
else sum = 1; --> sum = r % 2;


krs,
tesu

buddy1 commented: Very helpful +1
tesuji 135 Master Poster

The c++ function void binaryAdd(int* sum, int& cBit, const int* bin1, const int* bin2 ) cannot be altered. I would be thankful for any help solving this problem.

I am not that sure whether your question deals with my post #9, does it? Are there problems like how-to-change formal parameters of the function declaration or don't fit your actual parameters when calling this function? Are there any error messages?

tesuji 135 Master Poster

hi, I am glad that the categories tree now also works fine for you. You are absolutely right when adding a level because navigation is then sometimes easier. In my actual tree I have also a further category for categorizing the categories, you see? Additionally to the product data categorized by the leaf nodes there is a further table with attributes to gather common data of a product.

krs,
tesu

tesuji 135 Master Poster

hi usenthil75,

resultant table looks nice. Obviously scheduling problem on how to assign demands to resources. But it's rather impossible to figure out what strategy you have been using, you need to be more specific. Otherwise it is rather impossible to advise you an appropriate sql statement.

krs,
tesu

tesuji 135 Master Poster

Hi navneet1083,

I am not that sure whether the following sql statement would work correctly for your problem, but I have similar problem tested with my database where I have created subtotals with with-clause first then I "unioned" this result with grand total. Maybe you can try this:

with subtotals (n, ip, x, st) as
(  
   select cast(i as char), substring_index(source_ip, '.', i), 
      source_ip_new, count(*) as myCount
   from
   (select (1) as i union select (2) union select (3) union select (4)) as n
   join userbase_copy
     group by i, source_ip_new having i = 3 and count(*) > 0
   order by myCount desc
)
select * from  subtotals
union
select n, 'Total ', 'counts', sum(st) from subtotals

I simply copied your select statement and put it into (...) without checking it. Because columns of unions must be compatible, cast(i) might be necessary.

Ok, similar construct works fine on my tables. So I hope it also does it for your problem.
Tell me whether it works on your tables, maybe also the modifications you made.

krs,
tesu

tesuji 135 Master Poster

In the meantime you may try this famous paper: http://www.oberon.ethz.ch/WirthPubl/AD.pdf

tesuji 135 Master Poster

SEQUEL was predecessor of SQL. The Structured English QUEry Language, developed for System R by Boyce at IBM La Jolla Ca. in the early 1970. IBM changed SEQUEL to SQL due to legal reasons (British company of same name didn’t allow IBM to use this brand). Today IBM-guys pronounce SQL still SEE-QUEL. Rest of world usually pronounce it ESS-QUE-ELL. I personally prefer ESS-QUE-ELL. Well, MY-SEE-QUEL sounds somehow kind of factitious to me.

tesuji 135 Master Poster

Hi again,

you need to query the system tables (dictionary/catalogue) of MySql. Start with columns table.

krs,
tesu

tesuji 135 Master Poster

...If all redundant attributes are removed you get a subset what is called primary key...

I have to make an extension:
Sometimes there are more than one superkey of a relation. In such case also all redundant attributes have to be removed and the remaining subsets of attributes are then called CANDIDATE KEYS. Now one can freely select ONE of these candidate keys to identify the relation's tuples. In such case, this selected subset is called PRIMARY KEY.

krs,
tesu

tesuji 135 Master Poster

I'm trying to represent a number such as 1.45E-15 in C... How do i do this... I know there's pow() & exp() function but i don't think they are useful here...

Do you ask of how to convert 1.45E-15 in its binary IEEE 754(1987) floating point representation? For example, if length of exponent is 8 and length of mantissa is 23 bits (1+8+23 = 32 bit poor old float format) 1.45E-15 is 0 01001101 10100001111011110001110 where 0 = sign bit, 01001101 = exponent (effective exponent + bias 127dec), and 10100001111011110001110 = mantissa (without famous leftmost 1 what has usually been dropped, so effective mantissa would be: 1 10100001111011110001110)

Do you really mean this? If you want to make such conversion, you need to know three things: the length of exponent, the length of mantissa, and most important the bias of the exponent, for example for the old float format bias could be 127 or even 128. Do you know these parameters for your own conversion? If so, you can post them, and i would guide you step-by-step how to convert it merely manually:)

You may read this famous paper by Goldberg: http://www.validlab.com/goldberg/paper.pdf

krs,
tesu

tesuji 135 Master Poster

Correct me if I'm wrong, but that isn't ansi-c right?
Anyway, it's platform dependent. But for a Windows system Duoas' solution will work

True, they are taken from MFC class.

tesuji 135 Master Poster

. . .
Can you please help me with this by listing down the functions' syntax and their use.

Returning to the charge of harsh2327 s request, I personally think that http://www.cppreference.com/ offers a rather complete reference on c++. If you want to know something more about gcc, what is really much more than c++ only, http://gcc.gnu.org/onlinedocs/ would be a good resource.

krs,
tesu

tesuji 135 Master Poster

hmm... rechecking this... i dont think Code:Blocks comes with a compiler. it comes with the *ability* to use multiple compilers, but you have to provide them. if you dont provide your own, it defaults to expect the GCC compiler which, as far as I'm aware, doesnt exist on windows.
.

I don't think so.

jephthah commented: thanks for schooling me on that. i should try and shut up more often.... well, probably not.... +2
tesuji 135 Master Poster

Sorry, corretion:

Hi greeny,
... Our categories table (it slightly differs from below simple example) works great, and the table now has over 4000 categories and subcategories, still increasing...
tesu

We don't have 4000, sorry, only about 400 categories!

Need a little help for drawing the sample tree: it consists of one main category, three sub categories, two sub sub categories, and one sub sub sub category.

krs,
tesu

tesuji 135 Master Poster

Hi greeny,

There is no doubt that your doubt tells me you didn't understood anything of my sample code
neither you have drawn the tree of the example categories tree. If you don't understand this code, especially the primary, foreign keys and the insert statements, you may freely ask me.

First, I would advice you that you try to draw the categories tree from the given insert statements. Then compare it with your green bean example. What will you assess then? Yes, this very plain categories tree is already much more complex than your green bean example.

krs,
tesu

tesuji 135 Master Poster

Hi buddy1,

here is some code what might meet your assignment.

In your main() you write:

// Binary addition
const int a[8] = { 0, 1, 1, 1, 1, 1, 1, 1 };
const int b[8] = { 0, 0, 1, 1, 1, 1, 1, 1 };
int nb = 8, carry = 0, sum[8];

binaryAddint(nb, carry, sum, a, b);

cout << "\nOperand a:   "; for (int i = 0; i < nb; cout << a[i++]);
cout << "\nOperand b:   "; for (int i = 0; i < nb; cout << b[i++]);
cout << "\na plus b:    "; for (int i = 0; i < nb; cout << sum[i++]);
cout << "\nLast carray: " << carry << endl;

/* Result:
   Operand a:   01111111
   Operand b:   00111111
   a plus b:    10111110
   Last carray: 0
*/

Function to do the additions:

void binaryAddint( int nb, int& carry, int* sum, const int* bin1, const int* bin2 ){
  for ( int s, i = nb-1; i >= 0; i--){
    s = bin1[i] + bin2[i] + carry;
    sum[i] = s % 2; carry = s / 2;
  }
}

First, both binary figures and the carry will be added. That gives the sum s. sum s remainder 2 gives the new figure (e.g. 1 + 1 + 1 = 3 % 2 = 1). There is only a new carry if the sum is 2 or 3. So dividing the sum s by 2 gives carry (e.g. 0 + 1 + 1 = 2 / 2 = 1).

I hope this clarifies the problem.

krs,
tesu

tesuji 135 Master Poster

so why not telling us how to get that example code from INTEL side?

tesuji 135 Master Poster

For windows installations codeblocks usually contains the C++ compiler and some other compilers from GCC compiler collections and the GDB debugger from MinGW. This is an outstanding c++ compiler what is also available on unix and mac os. proprietary turbo c++ can not be compared with this ISO standard and posix compatible compiler.
Unfortunately, this IDE, written in Delphi/Kylix, has still some serious bugs, therefore efficient working is sometimes restricted. That s the reason why I am still using wxDev-C++.

tesuji 135 Master Poster

Maybe the net framework class library for xml which can virtually used with every programming languages (I myself use it together with c++) solves some of your problems.
http://msdn.microsoft.com/en-us/library/system.xml(VS.80).aspx
some years ago when i started with xml i really wrote my own xml parser an did manipulate xml files with plain string methods. Thanks net framework class lib now it s something easier to deal with xml.

krs,
tesu

tesuji 135 Master Poster

what is the purpose of BCNF and other ones?

To defeat the anomalies!

btw lich, there is more: BCNF, 4NF, 5NF, and 6NF (in concordance with C.J. Date).

Happy normalizations (as Nixon and Codd didn't say)!

krs,
tesu

tesuji 135 Master Poster

First of all, you must add PRIMARY keys and FOREIGN keys as well.
I don't know of crystal's limitations. Using standard sql you can clue those tables together by join operations, like this select * from A join B on A.field = B.field...
If crystal is unable to understand modern joins you can also use tradition inner joins like
select * from A, B where A.field = B.field...

tesuji 135 Master Poster

structured query language

tesuji 135 Master Poster

hi ceyesuma,

I have a database designed in Access. I would much rather use MySQL. Is there an IDE that I could use MySQL and work with building tables and ERD's?

You may have a look at DBDesigner by fabforce. But be aware of those really stupid errors this nice tool is still lacking of. If there are problems, you can ask me.

krs,
tesu

ps. I assumed that you already know phpadmin.