dev-cpp-users Mailing List for Dev-C++ (Page 31)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(15) |
Oct
(115) |
Nov
(154) |
Dec
(258) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(377) |
Feb
(260) |
Mar
(249) |
Apr
(188) |
May
(152) |
Jun
(150) |
Jul
(195) |
Aug
(202) |
Sep
(200) |
Oct
(286) |
Nov
(242) |
Dec
(165) |
2002 |
Jan
(245) |
Feb
(241) |
Mar
(239) |
Apr
(346) |
May
(406) |
Jun
(369) |
Jul
(418) |
Aug
(357) |
Sep
(362) |
Oct
(597) |
Nov
(455) |
Dec
(344) |
2003 |
Jan
(446) |
Feb
(397) |
Mar
(515) |
Apr
(524) |
May
(377) |
Jun
(387) |
Jul
(532) |
Aug
(364) |
Sep
(294) |
Oct
(352) |
Nov
(295) |
Dec
(327) |
2004 |
Jan
(416) |
Feb
(318) |
Mar
(324) |
Apr
(249) |
May
(259) |
Jun
(218) |
Jul
(212) |
Aug
(259) |
Sep
(158) |
Oct
(162) |
Nov
(214) |
Dec
(169) |
2005 |
Jan
(111) |
Feb
(165) |
Mar
(199) |
Apr
(147) |
May
(131) |
Jun
(163) |
Jul
(235) |
Aug
(136) |
Sep
(84) |
Oct
(88) |
Nov
(113) |
Dec
(100) |
2006 |
Jan
(85) |
Feb
(119) |
Mar
(33) |
Apr
(31) |
May
(56) |
Jun
(68) |
Jul
(18) |
Aug
(62) |
Sep
(33) |
Oct
(55) |
Nov
(19) |
Dec
(40) |
2007 |
Jan
(22) |
Feb
(49) |
Mar
(34) |
Apr
(51) |
May
(66) |
Jun
(43) |
Jul
(116) |
Aug
(57) |
Sep
(70) |
Oct
(69) |
Nov
(97) |
Dec
(86) |
2008 |
Jan
(32) |
Feb
(47) |
Mar
(106) |
Apr
(67) |
May
(28) |
Jun
(39) |
Jul
(31) |
Aug
(25) |
Sep
(18) |
Oct
(25) |
Nov
(5) |
Dec
(21) |
2009 |
Jan
(33) |
Feb
(27) |
Mar
(27) |
Apr
(22) |
May
(22) |
Jun
(10) |
Jul
(17) |
Aug
(9) |
Sep
(21) |
Oct
(13) |
Nov
(4) |
Dec
(11) |
2010 |
Jan
(10) |
Feb
(8) |
Mar
(4) |
Apr
(1) |
May
|
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(8) |
Oct
(26) |
Nov
(9) |
Dec
(1) |
2011 |
Jan
(21) |
Feb
(16) |
Mar
(4) |
Apr
(19) |
May
(26) |
Jun
(9) |
Jul
(6) |
Aug
|
Sep
(4) |
Oct
(3) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
(4) |
Feb
(7) |
Mar
(4) |
Apr
|
May
(1) |
Jun
(10) |
Jul
(1) |
Aug
(1) |
Sep
(18) |
Oct
(3) |
Nov
(1) |
Dec
(1) |
2013 |
Jan
(4) |
Feb
(2) |
Mar
(15) |
Apr
(6) |
May
(1) |
Jun
(3) |
Jul
(1) |
Aug
(2) |
Sep
(4) |
Oct
|
Nov
(9) |
Dec
|
2014 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(5) |
Aug
(4) |
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(4) |
2015 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
(2) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(2) |
Oct
(9) |
Nov
(35) |
Dec
(6) |
2016 |
Jan
(7) |
Feb
(10) |
Mar
(10) |
Apr
(9) |
May
(13) |
Jun
(9) |
Jul
(1) |
Aug
(3) |
Sep
(3) |
Oct
(1) |
Nov
(1) |
Dec
|
2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
(1) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Bruce F. (Stronsay) <ric...@bt...> - 2008-04-04 12:38:01
|
> why are they useless? why equal to 0? can i have more explanation? Let's take this bit of code: int loopb3() { for (n = 9; n >= 1; n--) b3 = n; return b3; } The function loopb3 has a "for..." loop which moves the value of b3 from 9 down to 0. It does nothing else. The function loopb3 will _always_ return 0, which is the final value of b3 after the loop is complete. -- Bruce Fletcher Stronsay, Orkney <www.stronsay.co.uk/claremont> |
From: Kenneth C. <ken...@ho...> - 2008-04-04 12:11:11
|
This is not an assignment. As I have included some information and comments within the code. With these information and short email messages should be able to know what the intention was. why it doesn't contain any loop? why it just returns a same value? is there some where i have used wrongly in the code?> Date: Fri, 4 Apr 2008 12:40:58 +0200> From: pw...@ia...> To: ken...@ho...> CC: dev...@li...> Subject: Re: [Dev-C++] info> > 1) That code is hurtful to see. How would it look if you had more numbers> with more digts? Think again, and simplify the code. It's a question of> algorithms. A good algorithm shouldd try to support varying limits without> changing the code - just the input parameters. Your code has hard-coded> expansions for all combinations.> > 2) What do you think your functions with for loops do?> int loopb1() {> for (l = 9; l >= 1; l--)> b1 = l;> return b1;> }> In reality it doesn't contain any loop, and will just return a fixed value> - the same value everytime the function is called.> > By the way: This is a school assignment, which means that you are expected> to spend your time trying to figure out a good solution to the problem.> You will not learn unless you spend the time.> > On the other hand, we don't even know what the assignment is. We may be> able to guess based on the code. But if your code solves the wrong thing,> we will not be able to know, since we don't know what the intention was.> All we can see is if the code performs it's job in a good way. In this> case, you have too much code expansion for that to be true. The code> should be simplified.> > /pwm> > On Fri, 4 Apr 2008, Kenneth Chung wrote:> > >> > hi All,> >> > multiplication.c is working fine as the output solution is correct.> >> > However, what is the problem with multiplication1.c? From there i have made some changes, i have included functions to shorten the for loops. Unfortunately there is no output solution. What is the problem? Is there an alternative to shorten the big bunch of if statement(at the bottom) and for loops(after main) to make it work?> >> > Please find below.> >> > regards,> > Kenneth> >> >> >> >> > Program: multiplication.c> >> > /******************************************************************************************************************************** * Description: Each star stands for a digit, with the leftmost star on each * * line with stars standing for a nonzero digit. This multiplication * * has 3 partial products (the three lines between the two * * * a1 a2 a3 * * horizontal bars). x * * * x b1 b2 b3 * * - all partial products are made up of the same digits (a given ----- -------- * * digit occurs in every partial product or in none of them); * * * * c1 c2 c3 c4 * * - the first and second partial products are different; * * * * d1 d2 d3 d4 * * - the orderings of digits in the second and third partial * * * * e1 e2 e3 e4 * * products are inverse of each other (such as 1424 and 4241); ----------- ----------------- * * - the third partial product is the sum of the first two * * * * * * * * * * * * * * partial products. * ********************************************************************************************************************************/> > #include <stdio.h>#include <stdlib.h>> > /* Define variables for use in the main() functions. */int a1, a2, a3, b1, b2, b3, c1, c2, c3, c4, d1, d2, d3, d4, e1, e2, e3, e4;int i, j, k, l, m, n, o, p, q, r, s, t, x, y, z;unsigned int mltply_1, mltply_2, partial_1, partial_2, partial_3, result;> > int main(void) { /* for() loops are being used to randomly assign a digit * * to each of the stars which is represented by variable * * a1, a2, a3, b1, b2 and b3. */ for (i = 9; i >= 1; i--) { a1 = i; for (j = 9; j >= 1; j--) { a2 = j; for (k = 9; k >= 1; k--) { a3 = k; for (l = 9; l >= 1; l--) { b1 = l; for (m = 9; m >= 1; m--) { b2 = m; for (n = 9; n >= 1; n--) { b3 = n; /* To calculate the value of mltply_1 and mltply_2 by * * using number in a1, a2, a3, b1, b2, b3. The result * * is assigned by multiplying both variable mltply_1 * * and mltply_2. */ mltply_1 = (a1 * 100) + (a2 * 10) + a3; mltply_2 = (b1 * 100) + (b2 * 10) + b3; result = mltply_1 * mltply_2; /* To compute the value of partial_1, partial_2 and partial_3. * * Each partial is strictly not less than 1000 as the leftmost * * star on each line with stars standing for a nonzero digit. * * If the value >= 1000 then it is assigned into variable * * partial_1, partial_2 and partial_3 */ if ((mltply_1 * b3 < 1000) || (mltply_1 * b2 < 1000) || (mltply_1 * b1 < 1000)) continue; partial_1 = mltply_1 * b3; partial_2 = mltply_1 * b2; partial_3 = mltply_1 * b1; /* Upon the values of 3 partial products have been computed * * into 4 digits, each partial may break into single digit * * from the 4 digits number for comparison check later. */ c1 = partial_1 / 1000; o = partial_1 % 1000; c2 = o / 100; p = o % 100; c3 = p / 10; q = p % 10; c4 = q / 1; d1 = partial_2 / 1000; r = partial_2 % 1000; d2 = r / 100; s = r % 100; d3 = s / 10; t = s % 10; d4 = t / 1; e1 = partial_3 / 1000; x = partial_3 % 1000; e2 = x / 100; y = x % 100; e3 = y / 10; z = y % 10; e4 = z / 1; /* All partial products are made up of the same digits. * * The first and second partial products are different. */ if ((c1 == d1) || (c1 == d2) || (c1 == d3) || (c1 == d4)) if ((c2 == d1) || (c2 == d2) || (c2 == d3) || (c2 == d4)) if ((c3 == d1) || (c3 == d2) || (c3 == d3) || (c3 == d4)) if ((c4 == d1) || (c4 == d2) || (c4 == d3) || (c4 == d4)) /* The orderings of digits in the second and third partial products * * are inverse of each other (such as 1424 and 4241). */ if ((d1 == e4) && (d2 == e3) && (d3 == e2) && (d4 == e1)) /* The third partial product is the sum of the first two * * partial products. */ if (partial_3 == (partial_1 + partial_2)) printf("%d x %d = %d, with %d, %d and %d as partial products, is a solution.", mltply_1, mltply_2, result, partial_1, partial_2, partial_3); } } } } } } system("PAUSE"); return EXIT_SUCCESS;}> >> >> >> > Program: Multiplication1.c> >> > /******************************************************************************************************************************** * Description: Each star stands for a digit, with the leftmost star on each * * line with stars standing for a nonzero digit. This multiplication * * has 3 partial products (the three lines between the two * * * a1 a2 a3 * * horizontal bars). x * * * x b1 b2 b3 * * - all partial products are made up of the same digits (a given ------ -------- * * digit occurs in every partial product or in none of them); * * * * c1 c2 c3 c4 * * - the first and second partial products are different; * * * * d1 d2 d3 d4 * * - the orderings of digits in the second and third partial * * * * e1 e2 e3 e4 * * products are inverse of each other (such as 1424 and 4241); ----------- ----------------- * * - the third partial product is the sum of the first two * * * * * * * * * * * * * * partial products. * * * ********************************************************************************************************************************/> > #include <stdio.h>#include <stdlib.h>> > /* Define variables for use in the main(), loopb1(), loopb2() and loopb3 functions. */int a1, a2, a3, b1, b2, b3, c1, c2, c3, c4, d1, d2, d3, d4, e1, e2, e3, e4;int i, j, k, l, m, n, o, p, q, r, s, t, x, y, z;unsigned int mltply_1, mltply_2, partial_1, partial_2, partial_3, result;> > /* Define Function Prototype */int loopb1();int loopb2();int loopb3();> > int main(void) { /* for() loops and function are being used to randomly assign a digit * * to each of the stars which is represented by variable a1, a2, a3, * * b1, b2 and b3. */ for (i = 9; i >= 1; i--) { a1 = i; for (j = 9; j >= 1; j--) { a2 = j; for (k = 9; k >= 1; k--) { a3 = k; /* Calling Functions */ b1 = loopb1(); b2 = loopb2(); b3 = loopb3(); /* To calculate the value of mltply_1 and mltply_2 by * * using number in a1, a2, a3, b1, b2, b3. The result * * is assigned by multiplying both variable mltply_1 * * and mltply_2. */ mltply_1 = (a1 * 100) + (a2 * 10) + a3; mltply_2 = (b1 * 100) + (b2 * 10) + b3; result = mltply_1 * mltply_2; /* To compute the value of partial_1, partial_2 and partial_3. * * Each partial is strictly not less than 1000 as the leftmost * * star on each line with stars standing for a nonzero digit. * * If the value >= 1000 then it is assigned into variable * * partial_1, partial_2 and partial_3 */ if ((mltply_1 * b3 < 1000) || (mltply_1 * b2 < 1000) || (mltply_1 * b1 < 1000)) continue; partial_1 = mltply_1 * b3; partial_2 = mltply_1 * b2; partial_3 = mltply_1 * b1; /* Upon the values of 3 partial products have been computed * * into 4 digits, each partial may break into single digit * * from the 4 digits number for comparison check later. */ c1 = partial_1 / 1000; o = partial_1 % 1000; c2 = o / 100; p = o % 100; c3 = p / 10; q = p % 10; c4 = q / 1; d1 = partial_2 / 1000; r = partial_2 % 1000; d2 = r / 100; s = r % 100; d3 = s / 10; t = s % 10; d4 = t / 1; e1 = partial_3 / 1000; x = partial_3 % 1000; e2 = x / 100; y = x % 100; e3 = y / 10; z = y % 10; e4 = z / 1; /* All partial products are made up of the same digits. * * The first and second partial products are different. */ if ((c1 == d1) || (c1 == d2) || (c1 == d3) || (c1 == d4)) if ((c2 == d1) || (c2 == d2) || (c2 == d3) || (c2 == d4)) if ((c3 == d1) || (c3 == d2) || (c3 == d3) || (c3 == d4)) if ((c4 == d1) || (c4 == d2) || (c4 == d3) || (c4 == d4)) /* The orderings of digits in the second and third partial products * * are inverse of each other (such as 1424 and 4241). */ if ((d1 == e4) && (d2 == e3) && (d3 == e2) && (d4 == e1)) /* The third partial product is the sum of the first two * * partial products. */ if (partial_3 == (partial_1 + partial_2)) printf("%d x %d = %d, with %d, %d and %d as partial products, is a solution.", mltply_1, mltply_2, result, partial_1, partial_2, partial_3); } } } system("PAUSE"); return EXIT_SUCCESS;}> > /* Function Definition */int loopb1() { for (l = 9; l >= 1; l--) b1 = l; return b1;}> > int loopb2() { for (m = 9; m >= 1; m--) b2 = m; return b2;}> > int loopb3() { for (n = 9; n >= 1; n--) b3 = n; return b3;}> > _________________________________________________________________> > Find the job of your dreams before someone else does> > http://mycareer.com.au/?s_cid=596064> > _________________________________________________________________ Find the job of your dreams before someone else does http://mycareer.com.au/?s_cid=596064 |
From: Kenneth C. <ken...@ho...> - 2008-04-04 11:41:47
|
why are they useless? why equal to 0? can i have more explanation?> Date: Fri, 4 Apr 2008 12:35:02 +0200> From: mi...@mo...> To: ken...@ho...> CC: dev...@li...> Subject: Re: [Dev-C++] info> > Kenneth Chung napsal(a):> > > /* Function Definition */> > int loopb1() {> > for (l = 9; l >= 1; l--)> > b1 = l;> > return b1;> > }> > int loopb2() {> > for (m = 9; m >= 1; m--)> > b2 = m;> > return b2;> > }> > int loopb3() {> > for (n = 9; n >= 1; n--)> > b3 = n;> > return b3;> > }> > These loops are useless, the code is equivalent to:> > int loopb1() {> b1 = 0;> return b1;> }> int loopb2() {> b2 = 0;> return b2;> }> int loopb3() {> b3 = 0;> return b3;> } _________________________________________________________________ Find the job of your dreams before someone else does http://mycareer.com.au/?s_cid=596064 |
From: Per W. <pw...@ia...> - 2008-04-04 10:41:14
|
1) That code is hurtful to see. How would it look if you had more numbers with more digts? Think again, and simplify the code. It's a question of algorithms. A good algorithm shouldd try to support varying limits without changing the code - just the input parameters. Your code has hard-coded expansions for all combinations. 2) What do you think your functions with for loops do? int loopb1() { for (l = 9; l >= 1; l--) b1 = l; return b1; } In reality it doesn't contain any loop, and will just return a fixed value - the same value everytime the function is called. By the way: This is a school assignment, which means that you are expected to spend your time trying to figure out a good solution to the problem. You will not learn unless you spend the time. On the other hand, we don't even know what the assignment is. We may be able to guess based on the code. But if your code solves the wrong thing, we will not be able to know, since we don't know what the intention was. All we can see is if the code performs it's job in a good way. In this case, you have too much code expansion for that to be true. The code should be simplified. /pwm On Fri, 4 Apr 2008, Kenneth Chung wrote: > > hi All, > > multiplication.c is working fine as the output solution is correct. > > However, what is the problem with multiplication1.c? From there i have made some changes, i have included functions to shorten the for loops. Unfortunately there is no output solution. What is the problem? Is there an alternative to shorten the big bunch of if statement(at the bottom) and for loops(after main) to make it work? > > Please find below. > > regards, > Kenneth > > > > > Program: multiplication.c > > /******************************************************************************************************************************** * Description: Each star stands for a digit, with the leftmost star on each * * line with stars standing for a nonzero digit. This multiplication * * has 3 partial products (the three lines between the two * * * a1 a2 a3 * * horizontal bars). x * * * x b1 b2 b3 * * - all partial products are made up of the same digits (a given ----- -------- * * digit occurs in every partial product or in none of them); * * * * c1 c2 c3 c4 * * - the first and second partial products are different; * * * * d1 d2 d3 d4 * * - the orderings of digits in the second and third partial * * * * e1 e2 e3 e4 * * products are inverse of each other (such as 1424 and 4241); ----------- ----------------- * * - the third partial product is the sum of the first two * * * * * * * * * * * * * * partial products. * ********************************************************************************************************************************/ > #include <stdio.h>#include <stdlib.h> > /* Define variables for use in the main() functions. */int a1, a2, a3, b1, b2, b3, c1, c2, c3, c4, d1, d2, d3, d4, e1, e2, e3, e4;int i, j, k, l, m, n, o, p, q, r, s, t, x, y, z;unsigned int mltply_1, mltply_2, partial_1, partial_2, partial_3, result; > int main(void) { /* for() loops are being used to randomly assign a digit * * to each of the stars which is represented by variable * * a1, a2, a3, b1, b2 and b3. */ for (i = 9; i >= 1; i--) { a1 = i; for (j = 9; j >= 1; j--) { a2 = j; for (k = 9; k >= 1; k--) { a3 = k; for (l = 9; l >= 1; l--) { b1 = l; for (m = 9; m >= 1; m--) { b2 = m; for (n = 9; n >= 1; n--) { b3 = n; /* To calculate the value of mltply_1 and mltply_2 by * * using number in a1, a2, a3, b1, b2, b3. The result * * is assigned by multiplying both variable mltply_1 * * and mltply_2. */ mltply_1 = (a1 * 100) + (a2 * 10) + a3; mltply_2 = (b1 * 100) + (b2 * 10) + b3; result = mltply_1 * mltply_2; /* To compute the value of partial_1, partial_2 and partial_3. * * Each partial is strictly not less than 1000 as the leftmost * * star on each line with stars standing for a nonzero digit. * * If the value >= 1000 then it is assigned into variable * * partial_1, partial_2 and partial_3 */ if ((mltply_1 * b3 < 1000) || (mltply_1 * b2 < 1000) || (mltply_1 * b1 < 1000)) continue; partial_1 = mltply_1 * b3; partial_2 = mltply_1 * b2; partial_3 = mltply_1 * b1; /* Upon the values of 3 partial products have been computed * * into 4 digits, each partial may break into single digit * * from the 4 digits number for comparison check later. */ c1 = partial_1 / 1000; o = partial_1 % 1000; c2 = o / 100; p = o % 100; c3 = p / 10; q = p % 10; c4 = q / 1; d1 = partial_2 / 1000; r = partial_2 % 1000; d2 = r / 100; s = r % 100; d3 = s / 10; t = s % 10; d4 = t / 1; e1 = partial_3 / 1000; x = partial_3 % 1000; e2 = x / 100; y = x % 100; e3 = y / 10; z = y % 10; e4 = z / 1; /* All partial products are made up of the same digits. * * The first and second partial products are different. */ if ((c1 == d1) || (c1 == d2) || (c1 == d3) || (c1 == d4)) if ((c2 == d1) || (c2 == d2) || (c2 == d3) || (c2 == d4)) if ((c3 == d1) || (c3 == d2) || (c3 == d3) || (c3 == d4)) if ((c4 == d1) || (c4 == d2) || (c4 == d3) || (c4 == d4)) /* The orderings of digits in the second and third partial products * * are inverse of each other (such as 1424 and 4241). */ if ((d1 == e4) && (d2 == e3) && (d3 == e2) && (d4 == e1)) /* The third partial product is the sum of the first two * * partial products. */ if (partial_3 == (partial_1 + partial_2)) printf("%d x %d = %d, with %d, %d and %d as partial products, is a solution.", mltply_1, mltply_2, result, partial_1, partial_2, partial_3); } } } } } } system("PAUSE"); return EXIT_SUCCESS;} > > > > Program: Multiplication1.c > > /******************************************************************************************************************************** * Description: Each star stands for a digit, with the leftmost star on each * * line with stars standing for a nonzero digit. This multiplication * * has 3 partial products (the three lines between the two * * * a1 a2 a3 * * horizontal bars). x * * * x b1 b2 b3 * * - all partial products are made up of the same digits (a given ------ -------- * * digit occurs in every partial product or in none of them); * * * * c1 c2 c3 c4 * * - the first and second partial products are different; * * * * d1 d2 d3 d4 * * - the orderings of digits in the second and third partial * * * * e1 e2 e3 e4 * * products are inverse of each other (such as 1424 and 4241); ----------- ----------------- * * - the third partial product is the sum of the first two * * * * * * * * * * * * * * partial products. * * * ********************************************************************************************************************************/ > #include <stdio.h>#include <stdlib.h> > /* Define variables for use in the main(), loopb1(), loopb2() and loopb3 functions. */int a1, a2, a3, b1, b2, b3, c1, c2, c3, c4, d1, d2, d3, d4, e1, e2, e3, e4;int i, j, k, l, m, n, o, p, q, r, s, t, x, y, z;unsigned int mltply_1, mltply_2, partial_1, partial_2, partial_3, result; > /* Define Function Prototype */int loopb1();int loopb2();int loopb3(); > int main(void) { /* for() loops and function are being used to randomly assign a digit * * to each of the stars which is represented by variable a1, a2, a3, * * b1, b2 and b3. */ for (i = 9; i >= 1; i--) { a1 = i; for (j = 9; j >= 1; j--) { a2 = j; for (k = 9; k >= 1; k--) { a3 = k; /* Calling Functions */ b1 = loopb1(); b2 = loopb2(); b3 = loopb3(); /* To calculate the value of mltply_1 and mltply_2 by * * using number in a1, a2, a3, b1, b2, b3. The result * * is assigned by multiplying both variable mltply_1 * * and mltply_2. */ mltply_1 = (a1 * 100) + (a2 * 10) + a3; mltply_2 = (b1 * 100) + (b2 * 10) + b3; result = mltply_1 * mltply_2; /* To compute the value of partial_1, partial_2 and partial_3. * * Each partial is strictly not less than 1000 as the leftmost * * star on each line with stars standing for a nonzero digit. * * If the value >= 1000 then it is assigned into variable * * partial_1, partial_2 and partial_3 */ if ((mltply_1 * b3 < 1000) || (mltply_1 * b2 < 1000) || (mltply_1 * b1 < 1000)) continue; partial_1 = mltply_1 * b3; partial_2 = mltply_1 * b2; partial_3 = mltply_1 * b1; /* Upon the values of 3 partial products have been computed * * into 4 digits, each partial may break into single digit * * from the 4 digits number for comparison check later. */ c1 = partial_1 / 1000; o = partial_1 % 1000; c2 = o / 100; p = o % 100; c3 = p / 10; q = p % 10; c4 = q / 1; d1 = partial_2 / 1000; r = partial_2 % 1000; d2 = r / 100; s = r % 100; d3 = s / 10; t = s % 10; d4 = t / 1; e1 = partial_3 / 1000; x = partial_3 % 1000; e2 = x / 100; y = x % 100; e3 = y / 10; z = y % 10; e4 = z / 1; /* All partial products are made up of the same digits. * * The first and second partial products are different. */ if ((c1 == d1) || (c1 == d2) || (c1 == d3) || (c1 == d4)) if ((c2 == d1) || (c2 == d2) || (c2 == d3) || (c2 == d4)) if ((c3 == d1) || (c3 == d2) || (c3 == d3) || (c3 == d4)) if ((c4 == d1) || (c4 == d2) || (c4 == d3) || (c4 == d4)) /* The orderings of digits in the second and third partial products * * are inverse of each other (such as 1424 and 4241). */ if ((d1 == e4) && (d2 == e3) && (d3 == e2) && (d4 == e1)) /* The third partial product is the sum of the first two * * partial products. */ if (partial_3 == (partial_1 + partial_2)) printf("%d x %d = %d, with %d, %d and %d as partial products, is a solution.", mltply_1, mltply_2, result, partial_1, partial_2, partial_3); } } } system("PAUSE"); return EXIT_SUCCESS;} > /* Function Definition */int loopb1() { for (l = 9; l >= 1; l--) b1 = l; return b1;} > int loopb2() { for (m = 9; m >= 1; m--) b2 = m; return b2;} > int loopb3() { for (n = 9; n >= 1; n--) b3 = n; return b3;} > _________________________________________________________________ > Find the job of your dreams before someone else does > http://mycareer.com.au/?s_cid=596064 |
From: Michal M. <mi...@mo...> - 2008-04-04 10:35:14
|
Kenneth Chung napsal(a): > /* Function Definition */ > int loopb1() { > for (l = 9; l >= 1; l--) > b1 = l; > return b1; > } > int loopb2() { > for (m = 9; m >= 1; m--) > b2 = m; > return b2; > } > int loopb3() { > for (n = 9; n >= 1; n--) > b3 = n; > return b3; > } These loops are useless, the code is equivalent to: int loopb1() { b1 = 0; return b1; } int loopb2() { b2 = 0; return b2; } int loopb3() { b3 = 0; return b3; } |
From: Kenneth C. <ken...@ho...> - 2008-04-04 10:01:19
|
hi All, multiplication.c is working fine as the output solution is correct. However, what is the problem with multiplication1.c? From there i have made some changes, i have included functions to shorten the for loops. Unfortunately there is no output solution. What is the problem? Is there an alternative to shorten the big bunch of if statement(at the bottom) and for loops(after main) to make it work? Please find below. regards, Kenneth Program: multiplication.c /******************************************************************************************************************************** * Description: Each star stands for a digit, with the leftmost star on each * * line with stars standing for a nonzero digit. This multiplication * * has 3 partial products (the three lines between the two * * * a1 a2 a3 * * horizontal bars). x * * * x b1 b2 b3 * * - all partial products are made up of the same digits (a given ----- -------- * * digit occurs in every partial product or in none of them); * * * * c1 c2 c3 c4 * * - the first and second partial products are different; * * * * d1 d2 d3 d4 * * - the orderings of digits in the second and third partial * * * * e1 e2 e3 e4 * * products are inverse of each other (such as 1424 and 4241); ----------- ----------------- * * - the third partial product is the sum of the first two * * * * * * * * * * * * * * partial products. * ********************************************************************************************************************************/ #include <stdio.h>#include <stdlib.h> /* Define variables for use in the main() functions. */int a1, a2, a3, b1, b2, b3, c1, c2, c3, c4, d1, d2, d3, d4, e1, e2, e3, e4;int i, j, k, l, m, n, o, p, q, r, s, t, x, y, z;unsigned int mltply_1, mltply_2, partial_1, partial_2, partial_3, result; int main(void) { /* for() loops are being used to randomly assign a digit * * to each of the stars which is represented by variable * * a1, a2, a3, b1, b2 and b3. */ for (i = 9; i >= 1; i--) { a1 = i; for (j = 9; j >= 1; j--) { a2 = j; for (k = 9; k >= 1; k--) { a3 = k; for (l = 9; l >= 1; l--) { b1 = l; for (m = 9; m >= 1; m--) { b2 = m; for (n = 9; n >= 1; n--) { b3 = n; /* To calculate the value of mltply_1 and mltply_2 by * * using number in a1, a2, a3, b1, b2, b3. The result * * is assigned by multiplying both variable mltply_1 * * and mltply_2. */ mltply_1 = (a1 * 100) + (a2 * 10) + a3; mltply_2 = (b1 * 100) + (b2 * 10) + b3; result = mltply_1 * mltply_2; /* To compute the value of partial_1, partial_2 and partial_3. * * Each partial is strictly not less than 1000 as the leftmost * * star on each line with stars standing for a nonzero digit. * * If the value >= 1000 then it is assigned into variable * * partial_1, partial_2 and partial_3 */ if ((mltply_1 * b3 < 1000) || (mltply_1 * b2 < 1000) || (mltply_1 * b1 < 1000)) continue; partial_1 = mltply_1 * b3; partial_2 = mltply_1 * b2; partial_3 = mltply_1 * b1; /* Upon the values of 3 partial products have been computed * * into 4 digits, each partial may break into single digit * * from the 4 digits number for comparison check later. */ c1 = partial_1 / 1000; o = partial_1 % 1000; c2 = o / 100; p = o % 100; c3 = p / 10; q = p % 10; c4 = q / 1; d1 = partial_2 / 1000; r = partial_2 % 1000; d2 = r / 100; s = r % 100; d3 = s / 10; t = s % 10; d4 = t / 1; e1 = partial_3 / 1000; x = partial_3 % 1000; e2 = x / 100; y = x % 100; e3 = y / 10; z = y % 10; e4 = z / 1; /* All partial products are made up of the same digits. * * The first and second partial products are different. */ if ((c1 == d1) || (c1 == d2) || (c1 == d3) || (c1 == d4)) if ((c2 == d1) || (c2 == d2) || (c2 == d3) || (c2 == d4)) if ((c3 == d1) || (c3 == d2) || (c3 == d3) || (c3 == d4)) if ((c4 == d1) || (c4 == d2) || (c4 == d3) || (c4 == d4)) /* The orderings of digits in the second and third partial products * * are inverse of each other (such as 1424 and 4241). */ if ((d1 == e4) && (d2 == e3) && (d3 == e2) && (d4 == e1)) /* The third partial product is the sum of the first two * * partial products. */ if (partial_3 == (partial_1 + partial_2)) printf("%d x %d = %d, with %d, %d and %d as partial products, is a solution.", mltply_1, mltply_2, result, partial_1, partial_2, partial_3); } } } } } } system("PAUSE"); return EXIT_SUCCESS;} Program: Multiplication1.c /******************************************************************************************************************************** * Description: Each star stands for a digit, with the leftmost star on each * * line with stars standing for a nonzero digit. This multiplication * * has 3 partial products (the three lines between the two * * * a1 a2 a3 * * horizontal bars). x * * * x b1 b2 b3 * * - all partial products are made up of the same digits (a given ------ -------- * * digit occurs in every partial product or in none of them); * * * * c1 c2 c3 c4 * * - the first and second partial products are different; * * * * d1 d2 d3 d4 * * - the orderings of digits in the second and third partial * * * * e1 e2 e3 e4 * * products are inverse of each other (such as 1424 and 4241); ----------- ----------------- * * - the third partial product is the sum of the first two * * * * * * * * * * * * * * partial products. * * * ********************************************************************************************************************************/ #include <stdio.h>#include <stdlib.h> /* Define variables for use in the main(), loopb1(), loopb2() and loopb3 functions. */int a1, a2, a3, b1, b2, b3, c1, c2, c3, c4, d1, d2, d3, d4, e1, e2, e3, e4;int i, j, k, l, m, n, o, p, q, r, s, t, x, y, z;unsigned int mltply_1, mltply_2, partial_1, partial_2, partial_3, result; /* Define Function Prototype */int loopb1();int loopb2();int loopb3(); int main(void) { /* for() loops and function are being used to randomly assign a digit * * to each of the stars which is represented by variable a1, a2, a3, * * b1, b2 and b3. */ for (i = 9; i >= 1; i--) { a1 = i; for (j = 9; j >= 1; j--) { a2 = j; for (k = 9; k >= 1; k--) { a3 = k; /* Calling Functions */ b1 = loopb1(); b2 = loopb2(); b3 = loopb3(); /* To calculate the value of mltply_1 and mltply_2 by * * using number in a1, a2, a3, b1, b2, b3. The result * * is assigned by multiplying both variable mltply_1 * * and mltply_2. */ mltply_1 = (a1 * 100) + (a2 * 10) + a3; mltply_2 = (b1 * 100) + (b2 * 10) + b3; result = mltply_1 * mltply_2; /* To compute the value of partial_1, partial_2 and partial_3. * * Each partial is strictly not less than 1000 as the leftmost * * star on each line with stars standing for a nonzero digit. * * If the value >= 1000 then it is assigned into variable * * partial_1, partial_2 and partial_3 */ if ((mltply_1 * b3 < 1000) || (mltply_1 * b2 < 1000) || (mltply_1 * b1 < 1000)) continue; partial_1 = mltply_1 * b3; partial_2 = mltply_1 * b2; partial_3 = mltply_1 * b1; /* Upon the values of 3 partial products have been computed * * into 4 digits, each partial may break into single digit * * from the 4 digits number for comparison check later. */ c1 = partial_1 / 1000; o = partial_1 % 1000; c2 = o / 100; p = o % 100; c3 = p / 10; q = p % 10; c4 = q / 1; d1 = partial_2 / 1000; r = partial_2 % 1000; d2 = r / 100; s = r % 100; d3 = s / 10; t = s % 10; d4 = t / 1; e1 = partial_3 / 1000; x = partial_3 % 1000; e2 = x / 100; y = x % 100; e3 = y / 10; z = y % 10; e4 = z / 1; /* All partial products are made up of the same digits. * * The first and second partial products are different. */ if ((c1 == d1) || (c1 == d2) || (c1 == d3) || (c1 == d4)) if ((c2 == d1) || (c2 == d2) || (c2 == d3) || (c2 == d4)) if ((c3 == d1) || (c3 == d2) || (c3 == d3) || (c3 == d4)) if ((c4 == d1) || (c4 == d2) || (c4 == d3) || (c4 == d4)) /* The orderings of digits in the second and third partial products * * are inverse of each other (such as 1424 and 4241). */ if ((d1 == e4) && (d2 == e3) && (d3 == e2) && (d4 == e1)) /* The third partial product is the sum of the first two * * partial products. */ if (partial_3 == (partial_1 + partial_2)) printf("%d x %d = %d, with %d, %d and %d as partial products, is a solution.", mltply_1, mltply_2, result, partial_1, partial_2, partial_3); } } } system("PAUSE"); return EXIT_SUCCESS;} /* Function Definition */int loopb1() { for (l = 9; l >= 1; l--) b1 = l; return b1;} int loopb2() { for (m = 9; m >= 1; m--) b2 = m; return b2;} int loopb3() { for (n = 9; n >= 1; n--) b3 = n; return b3;} _________________________________________________________________ Find the job of your dreams before someone else does http://mycareer.com.au/?s_cid=596064 |
From: Per W. <pw...@ia...> - 2008-04-03 04:51:25
|
Dev-C++ is an IDE, not a compiler. The Dev-C++ IDE is (normally) using the MinGW compiler. But you have the choice to select which version of MinGW you want to compile with. Your question should be: Does the MinGW version I'm using support C-99 or not? In short: google gcc for C-99 support. /pwm On Thu, 3 Apr 2008, Kenneth Chung wrote: > > Hi All, > > Does anyone know whether Bloodshed Dev-C++ version 4.01 is C-99 standard or not? Thank you. > > regards, > Kenneth > _________________________________________________________________ > It's simple! Sell your car for just $30 at CarPoint.com.au > http://a.ninemsn.com.au/b.aspx?URL=https%3A%2F%2Ffanyv88.com%3A443%2Fhttp%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641&_t=762955845&_r=tig_OCT07&_m=EXT |
From: Kenneth C. <ken...@ho...> - 2008-04-03 04:47:50
|
Hi All, Does anyone know whether Bloodshed Dev-C++ version 4.01 is C-99 standard or not? Thank you. regards, Kenneth _________________________________________________________________ It's simple! Sell your car for just $30 at CarPoint.com.au http://a.ninemsn.com.au/b.aspx?URL=https%3A%2F%2Ffanyv88.com%3A443%2Fhttp%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641&_t=762955845&_r=tig_OCT07&_m=EXT |
From: <Mat...@bm...> - 2008-04-02 15:03:49
|
I use this function which I got from S.C Wong from code project. It will round a double to two decimal places. You need to include math.h to use it though. // rounds a double variable to nPlaces decimal places double Round(double dbVal, int nPlaces /* = 0 */) { const double dbShift = pow(10.0, nPlaces); return floor(dbVal * dbShift + 0.5) / dbShift; } Hope that helps, MT ________________________________ From: dev...@li... [mailto:dev...@li...] On Behalf Of Deepesh Kapadia Sent: 02 April 2008 10:52 To: dev...@li... Subject: Re: [Dev-C++] Arry dimensions hello all, I have a question here.. How to set a float datatype's value to 2 decimal places?? and also wat code to use to set the currency value of value set in a float or double datatype??? Will it be the same as setting it to 2 dp, as in my first question??? please do reply, Thanx.. ==DK== This email was sent from an email account of BMW (UK) Manufacturing Limited. BMW (UK) Manufacturing Limited is a company registered in England and Wales with company number 3950868; and has its offices at Ellesfield Avenue, Bracknell, Berkshire, RG12 8TA; registered in England and Wales. The contents of this e-mail are confidential and may be privileged and subject to internal monitoring. If you are not the addressee indicated in this message, you may not copy, forward, disclose, deliver or otherwise use it or any part of it in any form whatsoever. You should then kindly notify the sender by replying to this message and destroy it thereafter. Opinions, conclusions and other information in this message that do not relate to the official business of any BMW Group Company shall be understood as neither given nor endorsed by them. |
From: Per W. <pw...@ia...> - 2008-04-02 13:17:13
|
You either don't (with normal 32-bit numbers you don't have to think about any carry for so small products...) If this is a school work, or you are implementing a big-number library working in decimal, you just have to keep an intermediate variable 'carry'. carry = 0; while (digit-columns to add) { column_sum = carry + digit + digit + digit + digit + ...; carry = column_sum / 10; column_sum %= 10; emit_digit(column_sum); } if (carry) emit_digit(carry); /pwm On Wed, 2 Apr 2008, Kenneth Chung wrote: > > Hi All, > > Consider a multiplication of the form > > > 9 9 9 > x 9 9 9 > ------ > 8 9 9 1 > 8 9 9 1 > 8 9 9 1 > ----------- > 9 9 8 0 0 1 <----result > > How do I program the result line using C code especially when the sum of numbers has 2 digits let say 10, 20 then the first digit which is the 1 or 2 has to be added to next column for next sum? > > Thanks for your help. > > regards, > Kenneth > _________________________________________________________________ > Search for local singles online @ Lavalife - Click here > http://a.ninemsn.com.au/b.aspx?URL=https%3A%2F%2Ffanyv88.com%3A443%2Fhttp%2Flavalife9%2Eninemsn%2Ecom%2Eau%2Fclickthru%2Fclickthru%2Eact%3Fid%3Dninemsn%26context%3Dan99%26locale%3Den%5FAU%26a%3D30290&_t=764581033&_r=email_taglines_Search_OCT07&_m=EXT |
From: Kenneth C. <ken...@ho...> - 2008-04-02 12:51:48
|
Hi All, Consider a multiplication of the form 9 9 9 x 9 9 9 ------ 8 9 9 1 8 9 9 1 8 9 9 1 ----------- 9 9 8 0 0 1 <----result How do I program the result line using C code especially when the sum of numbers has 2 digits let say 10, 20 then the first digit which is the 1 or 2 has to be added to next column for next sum? Thanks for your help. regards, Kenneth _________________________________________________________________ Search for local singles online @ Lavalife - Click here http://a.ninemsn.com.au/b.aspx?URL=https%3A%2F%2Ffanyv88.com%3A443%2Fhttp%2Flavalife9%2Eninemsn%2Ecom%2Eau%2Fclickthru%2Fclickthru%2Eact%3Fid%3Dninemsn%26context%3Dan99%26locale%3Den%5FAU%26a%3D30290&_t=764581033&_r=email_taglines_Search_OCT07&_m=EXT |
From: Deepesh K. <dee...@gm...> - 2008-04-02 09:51:57
|
hello all, I have a question here.. How to set a float datatype's value to 2 decimal places?? and also wat code to use to set the currency value of value set in a float or double datatype??? Will it be the same as setting it to 2 dp, as in my first question??? please do reply, Thanx.. ==DK== |
From: Wobien <roo...@pl...> - 2008-04-01 13:58:40
|
Hello Kenneth, On this list we dicuss subject in public, so that everybody can participate. So please if you answer, reply to all, so that everybody recieves it. Also, use plain text without attachments, so copy your code in the mail. I copied your code below, so that everybody can see what we are talking about. Your code compiles fine for me. As it is it does not give any results. There are several mistakes in it: 1. your for loops for i, j.....p start with i=1, j=2, k=3 etc. Why? O can be a digit between 1 and 9, so that is OK, but N can also be a digit between 1 and 9. You are excluding the possibility N=1 without any reason. The same for the others. 2. You compile the value of ONE. That is OK. But than you assign ONE + ONE to the variable TWO. But this way you do'nt know if this is the supposed value of TWO = ( T * 100) + (W * 10) + O I think you have to realise that in the block of code within the parentheses following the big if-statement, (so all your code from here onwards), all the digits O, N, E, T, W...V have a value. You have to check if these values match the requirements mentioned in the header of your program. The first (different digitis for different letters, is checked by the big if- statement. The second ( first digits must not be zero) you can look after by using the right start values in the for statements. the other three you still have to check. So calculate TWO, SEVEN and NINE the same way you calculated ONE, and than check of each of the requirements. For each check, use an if-statement and only execute the rest of the code if the requirement is fullfilled. /****************************************************************************** * Description: Assign in all possible ways a digit to each of the letters * * that occur in the words ONE, TWO, SEVEN and NINE, so that: * * - different digits are assigned to different letters; * * - the digit assigned to the first letter of each word * * is not zero; * * - the equality ONE + ONE = TWO holds; * * - SEVEN is a prime number; * * - NINE is a perfect square. * * * ******************************************************************************/#include <stdio.h>#include <stdlib.h>#include <stdbool.h>#include <math.h>int main(void) {int O, N, E, T, W, S, V, I;int i, j, k, l, m, n, o, p, x, y;unsigned int ONE, TWO, SEVEN, NINE;unsigned int a, b, c, d, sq_root_of_seven;/* for() loop is being used to randomly assign a digit to each of theletters * * that occur in the words ONE, TWO, SEVEN and NINE. Different letters are* * assigned distinct digits.*/ for (i = 1; i <= 9; i++) { O = i; for (j = 2; j <= 9; j++) { N = j; for (k = 3; k <= 9; k++) { E = k; for (l = 4; l <= 9; l++) { T = l; for (m = 5; m <= 9; m++) { W = m; for (n = 6; n <= 9; n++) { S = n; for (o = 7; o <= 9; o++) { V = o; for (p = 8; p <= 9; p++) { I = p; /* Check to ensure that every letter isnot equal to each other * * then assign into variable ONE, addthe value of ONE to ONE * * then assign it into variable TWO*/ if ((O != N) && (N != E) && (O != E) &&(T != W) && (W != O) && (T != O) && (S != E) && (E != V) && (V != N) &&(S != V) && (S != N) && (E != N) && (N != I) && (I != E) && (N != E) &&(S != T) && (S != W) && (S != O) && (E != T) && (E != W) && (V != T) &&(V != W) && (V != O) && (N != T) && (N != W) && (I != O) && (I != T) &&(I != W) && (I != S) && (I != V)) { ONE = (O * 100) + (N * 10) + E; TWO = ONE + ONE; /* To compute NINE is a perfectsquare with distinct digits. * * The lowest possible value for NINEis 2823, and the square * * root of 2823 is 53.13. To round itdown is equal to 53. * * The highest possible value forNINE is 9897, and the * * square root of 9897 is 99.48. Toround it down is equal to * * 99. The loop will take from thelowest value 53 until the * * highest value 99 then itterminates. From the result break * * each number digit and assign theminto letters N, I, N, E. * * Then compare the digits beingassigned in letters N, I, N, E * * with other digits being assignedin other letters to ensure * * they are not equal to each other.If any letter is equal to * * each other then look for nextiteration, else assign the * * value x * x to NINE and display itas one of the solutions. */ for (x = 53; x <= 99; x++) { a = x * x; N = a / 1000; b = a % 1000; I = b / 100; c = b % 100; N = c / 10; d = c % 10; E = d / 1; if ((N == I) || (I == E) || (N ==E) || (N == O) || (N == T) || (N == W) || (N == S) || (N == V) || (I ==O) || (I == T) || (I == W) || (I == S) || (I == V) || (E == O) || (E ==T) || (E == W) || (E == S) || (E == V)) continue; NINE = x * x; } /* To compute SEVEN is a prime numberwith distinct digits. * * Prime number is a number which canonly be divided by 1 and * * itself. In the for loop, the valueof SEVEN will only be modulus * * by any numbers except 1 and itselfto determine whether SEVEN is * * prime number or not. If theremainder is equal 0 then SEVEN is * * not prime number. If theremainder is not equal to 0 until the * * loop stops then SEVEN is primenumber. */ SEVEN = (S * 10000) + (E * 1000) + (V* 100) + (E * 10) + N; bool is_prime = true; sq_root_of_seven = sqrt(SEVEN); for (y = 2; y <= sq_root_of_seven;y++) if (SEVEN % y == 0) { is_prime = false; break; } if (is_prime) printf("one = %d, two = %d, seven= %d and nine = %d is a solution.\n", ONE, TWO, SEVEN, NINE); } } } } } } } } } system("PAUSE"); return EXIT_SUCCESS;}----- Original Message -----From: Kenneth ChungTo: WobienSent: Tuesday, April 01, 2008 11:44 AMSubject: RE: [Dev-C++] BloodShed Dev-C++Hi Wobien,Please find the attached file this program actually generated the mentionederror message upon compiling. If I try to comment out the specified linewhich complained by the compiler then it is able to compile. However, Ifind that the solutions don't look quite correct. Kindly to check my sourcecode whether my idea and program structure is on the right track. As I amnot a very experience programmer and new to C language. Appreciate yourhelp.regards,Kenneth> From: roo...@pl...> To: ken...@ho...; dev...@li...> Subject: Re: [Dev-C++] BloodShed Dev-C++> Date: Mon, 31 Mar 2008 14:10:50 +0200>> Hi Kenneth,> bool is a build-in datatype in C++, not in C. If you #include <stdbool.h>> you should be able to use it in C without problems.> '# recursion too deep' is not about an unrecognised datatype, but aboutthe> structure of your program.> Without seeing the program it is impossible to tell you what is wrong with> it,> so please copy the program into your mail.>> Wobien>> ----- Original Message -----> From: Kenneth Chung> To: dev...@li...> Sent: Monday, March 31, 2008 3:15 AM> Subject: [Dev-C++] BloodShed Dev-C++>>> Hi All,>> Currently I am using the BloodShed Dev-C++ version 4.01. When I includethe> #include <stdbool.h> and wish to use bool data type in my program howeverit> doesn't work. When I compile The error message shows '# recursion toodeep'> something like that.>> Kindly advise. Urgent!>> regards,> Kenneth>>> Click here Search for local singles online @ Lavalife.>>>> Click here Search for local singles online @ Lavalife.>>>> -------------------------------------------------------------------------> Check out the new SourceForge.net Marketplace.> It's the best place to buy or sell services for> just about anything Open Source.>http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace>>>> _______________________________________________> Dev-cpp-users mailing list> Dev...@li...> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users>Click here Fashion, beauty, health, relationship advice and horoscopes. |
From: <Mat...@bm...> - 2008-04-01 05:52:59
|
Try using a vector instead, they are resizable and have methods which return the size etc.. >-----Original Message----- >From: dev...@li... [mailto:dev-cpp-users- >bo...@li...] On Behalf Of Per Westermark >Sent: 01 April 2008 06:42 >To: Jan Mura >Cc: dev...@li... >Subject: Re: [Dev-C++] Arry dimensions > >No general way to find the size of an array. That is one of the reasons >for the STL container classes. > >Anyway, if you can see the definition of the array, you can write: > >#define NELEM(a) (sizeof(a)/sizeof(*(a))) > >char arr[] = {"one","two","three"}; >int arr_count = NELEM(arr); > >/pwm > >On Tue, 1 Apr 2008, Jan Mura wrote: > >> Hello, >> >> I would like to ask if there is a possibility to get a dimesion of an >arry. >> I have have got an array >> char arr[][] ={:one:, :two:, three:}, >> >> And I would like to go thru the whole arry or several members. So shuld I >> store the value 3 like an number of members? >> Or can I to found it generally. Took a look to array definition but have >not >> found anything. >> >> Thank you. >> >> Jan Mura >> jan...@vo... >> >> >> ------------------------------------------------------------------------ - >> Check out the new SourceForge.net Marketplace. >> It's the best place to buy or sell services for >> just about anything Open Source. >> >http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/market plac >e >> _______________________________________________ >> Dev-cpp-users mailing list >> Dev...@li... >> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm >> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users >> > > >----------------------------------------------------------------------- -- >Check out the new SourceForge.net Marketplace. >It's the best place to buy or sell services for >just about anything Open Source. >http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/market plac >e >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users This email was sent from an email account of BMW (UK) Manufacturing Limited. BMW (UK) Manufacturing Limited is a company registered in England and Wales with company number 3950868; and has its offices at Ellesfield Avenue, Bracknell, Berkshire, RG12 8TA; registered in England and Wales. The contents of this e-mail are confidential and may be privileged and subject to internal monitoring. If you are not the addressee indicated in this message, you may not copy, forward, disclose, deliver or otherwise use it or any part of it in any form whatsoever. You should then kindly notify the sender by replying to this message and destroy it thereafter. Opinions, conclusions and other information in this message that do not relate to the official business of any BMW Group Company shall be understood as neither given nor endorsed by them. |
From: Per W. <pw...@ia...> - 2008-04-01 05:42:35
|
No general way to find the size of an array. That is one of the reasons for the STL container classes. Anyway, if you can see the definition of the array, you can write: #define NELEM(a) (sizeof(a)/sizeof(*(a))) char arr[] = {"one","two","three"}; int arr_count = NELEM(arr); /pwm On Tue, 1 Apr 2008, Jan Mura wrote: > Hello, > > I would like to ask if there is a possibility to get a dimesion of an arry. > I have have got an array > char arr[][] ={:one:, :two:, three:}, > > And I would like to go thru the whole arry or several members. So shuld I > store the value 3 like an number of members? > Or can I to found it generally. Took a look to array definition but have not > found anything. > > Thank you. > > Jan Mura > jan...@vo... > > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: Jan M. <jan...@vo...> - 2008-04-01 05:32:20
|
Hello, I would like to ask if there is a possibility to get a dimesion of an arry. I have have got an array char arr[][] ={:one:, :two:, three:}, And I would like to go thru the whole arry or several members. So shuld I store the value 3 like an number of members? Or can I to found it generally. Took a look to array definition but have not found anything. Thank you. Jan Mura jan...@vo... |
From: Wobien <roo...@pl...> - 2008-03-31 12:11:34
|
Hi Kenneth, bool is a build-in datatype in C++, not in C. If you #include <stdbool.h> you should be able to use it in C without problems. '# recursion too deep' is not about an unrecognised datatype, but about the structure of your program. Without seeing the program it is impossible to tell you what is wrong with it, so please copy the program into your mail. Wobien ----- Original Message ----- From: Kenneth Chung To: dev...@li... Sent: Monday, March 31, 2008 3:15 AM Subject: [Dev-C++] BloodShed Dev-C++ Hi All, Currently I am using the BloodShed Dev-C++ version 4.01. When I include the #include <stdbool.h> and wish to use bool data type in my program however it doesn't work. When I compile The error message shows '# recursion too deep' something like that. Kindly advise. Urgent! regards, Kenneth Click here Search for local singles online @ Lavalife. Click here Search for local singles online @ Lavalife. ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ Dev-cpp-users mailing list Dev...@li... TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |
From: Per W. <pw...@ia...> - 2008-03-31 07:32:50
|
It doesn't matter what you can look up on the net. That just means that you don't have to buy books. However, how do you scan the net for information you don't know exits or concepts you don't know about? Most people aren't even able to find a single function in the C RTL or Win32 API, even if they know exactly what they need. How will people then be able to google for different uses of template functions, operator overloading, multiple inherritance, where to use the const keyword, smart algorithms, ... where you might have to know the solution you are looking for just to be able to figure out what search terms to use? An example: How do you google for smart pointers if you don't know about smart pointers? So how will an employer know that you have enough knowledge to actally be able to develop real applications? Having access to a fullset of API documentation doesn't really matter. Access to a full tool shop isn't enough to guarantee that a person may actually manage to build anything useful. When you already have a number of years in the busines, you have recommendations and references to show when you look for a new job. If you are looking for your first job as a developer, you must somehow figure out a way to convince a possible employer that you have potential? All companies doesn't have time/resources to let their candidates come and do in-house tests or do trial-out work for a couple of weeks/months. /pwm On Sun, 30 Mar 2008, Chris Miller wrote: > On Sun, Mar 30, 2008 at 3:46 AM, sam Ruma <as...@ya...> wrote: > > Is there any programming certificate in C++ which can > > prove somebody's C++ ability? > > Microsoft used to have a very good certification course, but I can't > find their C++ tracks any more. They're all phased out in favor of > C#. > > Many colleges offer computer science courses in C++. That's a good > place to look. > > Sun Microsystems also has Java certifications, so they might have > something in C++. I don't know for sure, since I never looked > specifically for C++ certs. > > So much of C++ is documented online now that it's mostly immaterial to > show a cert, since almost anyone with 1/4 of a brain can look it up on > the web. > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: Kenneth C. <ken...@ho...> - 2008-03-31 01:15:16
|
Hi All,Currently I am using the BloodShed Dev-C++ version 4.01. When I include the #include <stdbool.h> and wish to use bool data type in my program however it doesn't work. When I compile The error message shows '# recursion too deep' something like that.Kindly advise. Urgent!regards,Kenneth Click here Search for local singles online @ Lavalife. _________________________________________________________________ Search for local singles online @ Lavalife http://a.ninemsn.com.au/b.aspx?URL=https%3A%2F%2Ffanyv88.com%3A443%2Fhttp%2Flavalife9%2Eninemsn%2Ecom%2Eau%2Fclickthru%2Fclickthru%2Eact%3Fid%3Dninemsn%26context%3Dan99%26locale%3Den%5FAU%26a%3D30290&_t=764581033&_r=email_taglines_Search_OCT07&_m=EXT |
From: Chris M. <lor...@gm...> - 2008-03-30 20:19:49
|
On Sun, Mar 30, 2008 at 3:46 AM, sam Ruma <as...@ya...> wrote: > Is there any programming certificate in C++ which can > prove somebody's C++ ability? Microsoft used to have a very good certification course, but I can't find their C++ tracks any more. They're all phased out in favor of C#. Many colleges offer computer science courses in C++. That's a good place to look. Sun Microsystems also has Java certifications, so they might have something in C++. I don't know for sure, since I never looked specifically for C++ certs. So much of C++ is documented online now that it's mostly immaterial to show a cert, since almost anyone with 1/4 of a brain can look it up on the web. |
From: Michal M. <mi...@mo...> - 2008-03-30 20:18:41
|
frederico schardong napsal(a): > [Linker error] undefined reference to `usleep' > > I`m working in windows OS > usleep not present in Dev headfiles? Windows has no usleep, they have Sleep: http://msdn2.microsoft.com/en-us/library/ms686298(VS.85).aspx |
From: frederico s. <fre...@gm...> - 2008-03-30 19:51:53
|
[Linker error] undefined reference to `usleep' I`m working in windows OS usleep not present in Dev headfiles? |
From: Eric <eri...@wo...> - 2008-03-30 18:18:03
|
deeps6ix Well, even though other estimeed members have already answered this, let me explain why char is case-sensitive; I kinda get the feeling, by your question, you do not fully understand what a char is. The datatype 'char' is a "virtual conception", in that a 'char' = 1 byte, and represents an entry of ASCII table. The 'char' type does not exist in terms that it is really a integer. Every entry of the ASCII table features a value and a charater. the first 31 entries consist of teletype control codes, like carriage return legacy typewriter thing, that you had to do when you wanted to change lines. ) The following 96 entries features common letters, numbers and pontuaction stuff. This, obviously represents the first 127 entries, that are, also the maximum value a byte ( signed ) can achive... but looking into ASCII table reveals Value('M') = 77 and Value('m') = 109, therefore 'm' != 'M' Check out this code, execution gives more info : <CODE LANG="C"> #include <stdio.h> int ReturnBytesInChar( unsigned char ch ) { /* Right shhifts bits out, to AND with 0000 0001*/ int i; for ( i=7*sizeof( char ) ; i >=0 ; i-- ) printf("%d", (ch >> i) & 1 ); } int ReturnBytesInInt( unsigned int ch ) { int i; for ( i=7*sizeof(int) ; i >=0 ; i-- ) printf("%d", ( ch >> i ) & 1); } int main () { char a = 'a'; unsigned int aIntegerValue = 97; unsigned int Draw; printf("Is a char = \'a\' equal a int = 97?\n\n"); if ( a == aIntegerValue ) printf("Wow, they do ? WTF!"); else printf("Nah! this guys is full of bollogny"); // This will never happen!!! heheh humor, hehe printf ("\n\nBut.. numbers of bytes allocatted for a char variable are %d and for a integer one %d\n...How can this be?", sizeof(char),sizeof(int)); printf("\n\nSimple dude :\n Check this table :\n"); for ( Draw^=Draw ; Draw != 9+sizeof(int)*7; Draw ++ ) putchar('-'); printf("\n\nChar bytes\t:\t%d\nVarDump:", sizeof( char ) ); ReturnBytesInChar( a ); printf("\n\nInt var bytes\t:\t%d\nVarDump:", sizeof( int ) ); ReturnBytesInInt( aIntegerValue ); putchar(10); for ( Draw^=Draw ; Draw != 9+sizeof(int)*7; Draw ++ ) putchar('-'); printf("\nNotice the similarities ? from the %do byte to the %do of integer the value equals \rchar's %d byte%c\n", sizeof(unsigned int)-1, sizeof(unsigned int), sizeof(char), (sizeof(char)>1) ? 's':' '); printf("What about diferent capitalizations? \'m\' and \'M\'?\nComputer see them as their values, and not letters...\n"); printf("See it as :\n\n\tAs value(\'m\') != value(\'M\') =>(implies)\n\t\t 'M' != 'm' \nAnd we can see it by the same functions above..."); printf("mess with them, and learn... and \rsee functions like fgetc() and try to understand why they are \'buggy\'"); scanf("%c",&a); } </CODE> Date: Sat, 29 Mar 2008 11:20:28 +1200 From: dee...@gm... To: dev...@li... Subject: [Dev-C++] Char datatype hello all, i would like to know if the CHAR datatype is case-sensitive?? i.e. should i write code like this to recognise the character or not e.g. char = category; if (category == 'M') or (category == 'm') cheers.. -- ---Deepesh Kapadia--- Veja mapas e encontre as melhores rotas para fugir do trânsito com o Live Search Maps! Experimente já! ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ Dev-cpp-users mailing list Dev...@li... TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm https://lists.sourceforge.net/lists/listinfo/dev-cpp-users No virus found in this incoming message. Checked by AVG. Version: 7.5.519 / Virus Database: 269.22.1/1349 - Release Date: 29-Mar-08 5:02 PM |
From: Pink B. <da...@ya...> - 2008-03-30 17:16:33
|
Per Westermark sez, > No, I do not think you understand the other warnings. > > You should not treat them as warnings, since in reality > they are not warnings but errors. You have completely > misunderstood the strcat() function. Um... it's not that its just a misunderstanding of what a string is in C. In a lot of languages, strings are really strings, with a defined length, and helpful built in stuff to allocate memory for them etc etc. In C a string is nothing more than an static array of char. Hopefully with a NULL char marking the end of the string. Thats hopefully because if it's not there then really bad things happen because C doesn't have bounds checking on arrays. Which means it's very easy to do things like copy data past the end of a string, thus corrupting memory. PS: When I get a warning I always look to see what is causing it and then do the appropriate cast or what not to make it go away. Mr Foo |
From: hhh h. <the...@ho...> - 2008-03-30 16:57:08
|
Jan : Hi there :D I'll assume you've read the excellent response by Per Westermark, so your prob is WinMain@16 ? well, this actually is a Linker error... the linker is complaining because PE files do contain, like every other executable formats an Entry Point. This, in C, are main our WinMain functions ( the latter in case, of win32 executables obviously. ) now if you do not provide a entry point for your program then there is no way the linker can calculate the offset of your functions,Data, and ultimatly instructions from the starting address, the latter being *roughfly* the entry point(main/WinMain)... :D Get it ? > From: jan...@vo...> To: dev...@li...> Date: Sun, 30 Mar 2008 03:49:35 +0200> Subject: [Dev-C++] The Winmain function> > Hello,> > maybe it is clear but I am a little bit confused.> > This is the source code:> > #include<stdio.h>> #include<string.h>> > const char *module_name = "conf_proces.c";> > const char *conf_file_name = "..\\conf\\conf.xml";> > int conf_file_read(const char *in_conf_file_name)> {> const char *function_name = "conf_file_read";> const char *err_msg;> int i;> FILE *p_fo;> > /*open and read the conf file*/> if ((p_fo = fopen (conf_file_name, "r")) == NULL)> {> /* ERROR PROCESSING */> err_msg = strcat ("Cannot open the configuration file: ", strcat> (in_conf_file_name, "\n"));> /* write_err (module_name, function_name, err_msg); */> }> > > if ( (i = (fclose (p_fo) != 0)))> {> /* ERROR PROCESSING */> err_msg = strcat ("Cannot close the configuration file: ", strcat> (in_conf_file_name, "\n"));> /* write_err (module_name, function_name, err_msg); */> }> return 0;> }> > And this is the gcc outpput:> C:\Documents and Settings\Jan Mura\_myhome\dev\dialogues\src>gcc > conf_process.c> conf_process.c: In function `conf_file_read':> conf_process.c:27: warning: passing arg 1 of `strcat' discards qualifiers > from p> ointer target type> conf_process.c:36: warning: passing arg 1 of `strcat' discards qualifiers > from p> ointer target type> C:/Dev-Cpp/bin/../lib/gcc/mingw32/3.4.2/../../../libmingw32.a(main.o)(.text+0x10> 6):main.c: undefined reference to `WinMain@16'> collect2: ld returned 1 exit status> > It is ok with these warnings, I understand it.> But I don't understand what means the error message about the WinMain > function. There is no main neither WinMain. I don't use windows.h, Win > components or anything like that.> > Jan Mura> jan...@vo...> > > > -------------------------------------------------------------------------> Check out the new SourceForge.net Marketplace.> It's the best place to buy or sell services for> just about anything Open Source.> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace> _______________________________________________> Dev-cpp-users mailing list> Dev...@li...> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users _________________________________________________________________ Instale a Barra de Ferramentas com Desktop Search e ganhe EMOTICONS para o Messenger! É GRÁTIS! http://www.msn.com.br/emoticonpack |