Thread: [Dev-C++] (no subject) (Page 10)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
From: David M. <ci...@ya...> - 2003-10-08 03:19:29
|
Ok how are overflows handled in C++ for integer types? I know about the resulting (number % upper_limit) effect which is actually what I want. What I am interested in is determining that an overflow has occurred. So far my searches into the void ... whoops meant the C++ standard, seem to suggest a exception is thrown when a overflow occurs, however I am under the impression exceptions are not exactly completely portable just yet, or am I wrong in this belief? The code makes use of classes so I am fairly confident that exceptions are portably supported the question is whether the exception is thrown for this exception. The following chunk of the standard should explain why I am not too sure about this. -- Begin Quote -- [Note: operators can be regrouped according to the usual mathematical rules only where the operators really are associative or commutative.9) For example, in the following fragment int a, b; /*...*/ a = a + 32760 + b + 5; the expression statement behaves exactly the same as a = (((a + 32760) + b) + 5); due to the associativity and precedence of these operators. Thus, the result of the sum (a + 32760) is next added to b, and that result is then added to 5 which results in the value assigned to a. On a machine in which overflows produce an exception and in which the range of values representable by an int is [ 32768,+32767], the implementation cannot rewrite this expression as a = ((a + b) + 32765); since if the values for a and b were, respectively, 32754 and 15, the sum a + b would produce an exception while the original expression would not; nor can the expression be rewritten either as a = ((a + 32765) + b); or a = (a + (b + 32765)); since the values for a and b might have been, respectively, 4 and 8 or 17 and 12. However on a machine in which overflows do not produce an exception and in which the results of overflows are reversible, the above expression statement can be rewritten by the implementation in any of the above ways because the same result will occur. ] -- End Quote -- This seems to indicate that the overflow is only thrown on machines that produce some sort of exception when an overflow occurs. Also a similar exception class exist for underflows the structure seems to be extremely similar to the overflow, I assume if one works then so does the other. Also is there some mathematical way to detect such an overflow? So far I am not finding any way, as the result can potentially be anywhere within the full range of numbers represent by the data type. I would rather not try to determine if an overflow would occur by performing the addition myself in binary as I am exploring this method to try to increase the efficiency of my algorithm and doing the addition "by hand" would severely increase the complexity of my algorithm. Thanks in Advance David McKen P.S. In case you are wondering this is not homework but a BigInt class I am trying to create. --------------------------------- Do you Yahoo!? The New Yahoo! Shopping - with improved product search |
From: Eric <eri...@cl...> - 2003-10-08 20:47:22
|
this "dorkie black font on white HTML Email" came in at 13K in file size I have converted it to plain text email you will notice the drop in file size, yet looks just the same as the original email "black font on white" for more reading http://www.georgedillon.com/web/html_email_is_evil.shtml (7 REASONS WHY HTML E-MAILS ARE EVIL.) ----- Original Message ----- From: David McKen To: Dev-Cpp Mailing List Sent: Wednesday, October 08, 2003 4:19 PM Subject: [Dev-C++] (no subject) Ok how are overflows handled in C++ for integer types? I know about the resulting (number % upper_limit) effect which is actually what I want. What I am interested in is determining that an overflow has occurred. So far my searches into the void ... whoops meant the C++ standard, seem to suggest a exception is thrown when a overflow occurs, however I am under the impression exceptions are not exactly completely portable just yet, or am I wrong in this belief? The code makes use of classes so I am fairly confident that exceptions are portably supported the question is whether the exception is thrown for this exception. The following chunk of the standard should explain why I am not too sure about this. -- Begin Quote -- [Note: operators can be regrouped according to the usual mathematical rules only where the operators really are associative or commutative.9) For example, in the following fragment int a, b; /*...*/ a = a + 32760 + b + 5; the expression statement behaves exactly the same as a = (((a + 32760) + b) + 5); due to the associativity and precedence of these operators. Thus, the result of the sum (a + 32760) is next added to b, and that result is then added to 5 which results in the value assigned to a. On a machine in which overflows produce an exception and in which the range of values representable by an int is [- 32768,+32767], the implementation cannot rewrite this expression as a = ((a + b) + 32765); since if the values for a and b were, respectively, - 32754 and - 15, the sum a + b would produce an exception while the original expression would not; nor can the expression be rewritten either as a = ((a + 32765) + b); or a = (a + (b + 32765)); since the values for a and b might have been, respectively, 4 and - 8 or - 17 and 12. However on a machine in which overflows do not produce an exception and in which the results of overflows are reversible, the above expression statement can be rewritten by the implementation in any of the above ways because the same result will occur. ] -- End Quote -- This seems to indicate that the overflow is only thrown on machines that produce some sort of exception when an overflow occurs. Also a similar exception class exist for underflows the structure seems to be extremely similar to the overflow, I assume if one works then so does the other. Also is there some mathematical way to detect such an overflow? So far I am not finding any way, as the result can potentially be anywhere within the full range of numbers represent by the data type. I would rather not try to determine if an overflow would occur by performing the addition myself in binary as I am exploring this method to try to increase the efficiency of my algorithm and doing the addition "by hand" would severely increase the complexity of my algorithm. Thanks in Advance David McKen P.S. In case you are wondering this is not homework but a BigInt class I am trying to create. Do you Yahoo!? The New Yahoo! Shopping - with improved product search |
From: <meh...@tu...> - 2003-10-13 00:55:25
|
*********************************************************************** Bu elektronik posta ve onunla iletilen b=FCt=FCn dosyalar sadece = g=F6ndericisi taraf=FDndan almas=FD ama=E7lanan yetkili ger=E7ek ya da = t=FCzel ki=FEinin kullan=FDm=FD i=E7indir.E=F0er s=F6z konusu yetkili = al=FDc=FD de=F0ilseniz bu elektronik postan=FDn i=E7eri=F0ini = a=E7=FDklaman=FDz,kopyalaman=FDz, y=F6nlendirmeniz ve kullanman=FDz = kesinlikle yasakt=FDr ve bu elektronik postay=FD derhal silmeniz = gerekmektedir TURKCELL bu mesaj=FDn i=E7erdi=F0i bilgilerin do=F0rulu=F0u veya = eksiksiz oldu=F0u konusunda herhangi bir garanti vermemektedir. Bu = nedenle bu bilgilerin ne =FEekilde olursa olsun i=E7eri=F0inden, = iletilmesinden, al=FDnmas=FDndan ve saklanmas=FDndan sorumlu de=F0ildir. = Bu mesajdaki g=F6r=FC=FEler yaln=FDzca g=F6nderen ki=FEiye aittir ve = TURKCELL'in g=F6r=FC=FElerini yans=FDtmayabilir Bu e-posta bilinen b=FCt=FCn bilgisayar vir=FCslerine kar=FE=FD = taranm=FD=FEt=FDr. *********************************************************************** This e-mail and any files transmitted with it are confidential and = intended solely for the use of the individual or entity to whom they are = addressed. If you are not the intended recipient you are hereby notified = that any dissemination, forwarding, copying or use of any of the = information is strictly prohibited, and the e-mail should immediately be = deleted. TURKCELL makes no warranty as to the accuracy or completeness of any = information contained in this message and hereby excludes any liability = of any kind for the information contained therein or for the information = transmission, reception, storage or use of such in any way = whatsoever.The opinions expressed in this message belong to sender alone = and may not necessarily reflect the opinions of TURKCELL. This e-mail has been scanned for all known computer viruses. *********************************************************************** |
From: Smitha V. B. <smi...@so...> - 2003-10-21 13:20:40
|
hi, I tried to connect one client program in one linux machine to communicate another server program in another machine using sockets. When once i use one port,if i try to use the same port again..It is saying that connection refused. When i give netstat command,it is showing all these ports in CLOSE_WAIT state.. What should i do to use the same port after i close the socket in my program.. Can anybody help me... All earlier help from this group help me lot to go forward... Forgive me for my bad english.. regds smitha |
From: Per W. <pw...@ia...> - 2003-10-21 23:14:08
|
This is a normal behaviour. The TCP stack has a timeout time how long it should block a socket from being reused. If you do int i = 1; setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(char*)&i,sizeof(i)); you tell the stack that you don't want this behaviour. Then you don't have to wait 90 seconds or whatever default value the stack is using. /Per W > hi, > I tried to connect one client program in one linux machine to communicate > another server > program in another machine using sockets. > When once i use one port,if i try to use the same port again..It is saying > that connection refused. > When i give netstat command,it is showing all these ports in CLOSE_WAIT > state.. > What should i do to use the same port after i close the socket in my > program.. > Can anybody help me... > All earlier help from this group help me lot to go forward... > Forgive me for my bad english.. > regds > smitha > > > > > ------------------------------------------------------- > This SF.net email is sponsored by OSDN developer relations > Here's your chance to show off your extensive product knowledge > We want to know what you know. Tell us and you have a chance to win $100 > http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54 > _______________________________________________ > 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: <Esc...@ne...> - 2003-11-06 06:05:13
|
Hey folks! I have messed up the settings in Dev-C++. Can anyone tell me where or how do I get the default settings? TIA __________________________________________________________________ McAfee VirusScan Online from the Netscape Network. Comprehensive protection for your entire computer. Get your free trial today! http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397 Get AOL Instant Messenger 5.1 free of charge. Download Now! http://aim.aol.com/aimnew/Aim/register.adp?promo=380455 |
From: <gty...@co...> - 2003-11-16 03:19:27
|
confirm 786008 |
From: Smitha V. B. <smi...@so...> - 2003-12-04 07:19:00
|
Does anybody know abt the documentation abt PCthreads..(A userspace thread library confirming to POSIX standards.) regards smitha > -----Original Message----- > From: P.T. Waugh MA [SMTP:pt...@ea...] > Sent: Thursday, December 04, 2003 12:42 PM > To: dev...@li... > Subject: [Dev-C++] @c #include > > What does this phrase mean? In short, what does this type of include look > > like vs. others? > > /** @file stack > * This is a Standard C++ Library header. You should @c #include this > header > * in your programs, rather than any of the "st[dl]_*.h" implementation > files. > */ > > This was found in the "stack" library. > > Thanks for your assistance. > > Patrick > > > > ------------------------------------------------------- > This SF.net email is sponsored by OSDN's Audience Survey. > Help shape OSDN's sites and tell us what you think. Take this > five minute survey and you could win a $250 Gift Certificate. > http://www.wrgsurveys.com/2003/osdntech03.php?site=8 > _______________________________________________ > 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 ********************************************************************* Disclaimer: The information in this e-mail and any attachments is confidential / privileged. It is intended solely for the addressee or addressees. If you are not the addressee indicated in this message, you may not copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer does not consent to Internet email for messages of this kind. ********************************************************************* |
From: neo <de...@ey...> - 2004-01-01 08:56:52
|
hi, happy new year! this is the first question of mine this year.:) Question: How to convert the a double date into a string,without using some certain function of the library? I need your code(*.C),thx in advance. --http://www.eyou.com --Îȶ¨¿É¿¿µÄµç×ÓÐÅÏä ÓïÒôÓʼþ ÒÆ¶¯ÊéÇ© ÈÕÀú·þÎñ ÍøÂç´æ´¢...ÒÚÓÊδ¾¡ --http://vip.eyou.com --¿ì¿ìµÇ¼ÒÚÓÊVIPÐÅÏä ×¢²áÄúÖÐÒâµÄÓû§Ãû |
From: Tim S. <ti...@we...> - 2004-01-01 10:57:03
|
Hi 'neo', you have written: > Question: How to convert the a double date into a string,without using > some certain function of the library? If you would use C++ this would be very easy with use of the stringstream class. Writing your own function is not hard but needs a bit time. You have to split your double into the float part and an integer part. double flnumber = 233.141592; int integerpart = (int) pi; double floatpart = ((int)pi) - pi; std::string number; Now you must parse your integerpart with something like this: while(integerpart <= 0) { number.append(int2char(integerpart - ((integerpart / 10)* 10)); integepart /= 10; } char int2char(int digit) { switch(digit) { case 0: return '0'; break; ... default: return '\0'; break; } } Now we are comming to the floatpart: number.append(","); while (floatpart <= 0) { number.append(int2char((int)(floatpart * 10))); floatpart *= 10; } No guarantee that it works, but I think you get the idea how it should be done. so long Tim -- http://we-are-teh-b.org/~tim/borg.key |
From: Per W. <pw...@ia...> - 2004-01-01 17:49:57
|
Besides forgetting a subject - making it a bit hard to keep track of question and answers - you also forgot to mention who created the double date for you. Why is that important? Simple: You convert from double to date using reverse algorithm from what created the double. Different OS uses different date formats. The scaling might differ - is 1.0 24 hours or 1 second or what? The offset might differ. Year 0 might be 1980, 1900, 0000 or whatever. /Per W On 1 Jan 2004, neo wrote: > hi, > > happy new year! > > this is the first question of mine this year.:) > > Question: How to convert the a double date into a string,without using so= me > certain function of the library? > > I need your code(*.C),thx in advance. > > > > > > > --http://www.eyou.com > --=CE=C8=B6=A8=BF=C9=BF=BF=B5=C4=B5=E7=D7=D3=D0=C5=CF=E4 =D3=EF=D2=F4=D3= =CA=BC=FE =D2=C6=B6=AF=CA=E9=C7=A9 =C8=D5=C0=FA=B7=FE=CE=F1 =CD=F8=C2=E7= =B4=E6=B4=A2...=D2=DA=D3=CA=CE=B4=BE=A1 > > --http://vip.eyou.com > --=BF=EC=BF=EC=B5=C7=C2=BC=D2=DA=D3=CAVIP=D0=C5=CF=E4 =D7=A2=B2=E1=C4=FA= =D6=D0=D2=E2=B5=C4=D3=C3=BB=A7=C3=FB > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: IBM Linux Tutorials. > Become an expert in LINUX or just sharpen your skills. Sign up for IBM's > Free Linux Tutorials. Learn everything from the bash shell to sys admin. > Click now! http://ads.osdn.com/?ad_id=3D1278&alloc_id=3D3371&op=3Dclick > _______________________________________________ > 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: peter n. <co...@fr...> - 2004-01-08 21:59:19
|
confirm 482445 |
From: Hung D. Le-p. <din...@ya...> - 2004-01-19 01:35:35
|
Hi, My name is Hung. I downloaded the devcpp4980 a few months ago. I installed it and tried countless of times but the one and only error i got is "unable to run the program" which i don't understand why because i follow steps in help menu. Even when i activated the program samples, still the same error everytime. So please help me fix it. I'd really appreciate that so much. By the way, my computer window is an XP. Please reply soon!!! __________________________________ Do you Yahoo!? Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes http://hotjobs.sweepstakes.yahoo.com/signingbonus |
From: belvale l. <wi...@al...> - 2004-01-21 19:46:15
|
Hello. I've try to import the source code of a program I made with Tclite in Dev-cpp. This program was using the graphics.h library and I changed it for the winbgim.h & winbgim.cpp from the CLGDI devpack. Now, I can't use the randomize function and I get a lot of linker errors such as these one : [Linker error] undefined reference to `SelectObject@8' [Linker error] undefined reference to `SelectObject@8' [Linker error] undefined reference to `ExtCreatePen@20' ... And one of these errors is linked with a strange file : C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ccoJaaaa.o(.text+0x4228) more undefined references to `DeleteObject@4' follow Could somebody help ? Thank you in advance Louis --------------------------------------------- Alinto wishes you a happy new year 2004 http://www.alinto.com |
From: Jens T. <Tu...@gm...> - 2004-01-22 17:02:22
|
<Hello, <Finally, the source compiled Ok. But when I tried to use the debug <feature of Dev-C++, the blue cursor doesn't appear in the code. I <compiled the source with the "Generate debugging information" option, <and the parameters -g and -gcoff in the compiler options, and doesn't do <the job. <Maybe there is a trick, or the like... < <Thanks in advance. < <Juan Hi I had the same problems with getting the debugger started, but then someone advised me to put the parameter -g3 to the compiler options. Since then it's been working. Jens -- +++ GMX - die erste Adresse für Mail, Message, More +++ Bis 31.1.: TopMail + Digicam für nur 29 EUR http://www.gmx.net/topmail |
From: Juan J. C. L. <jua...@ya...> - 2004-01-22 21:20:05
|
Jens, I looked in the Output Debugger message, and says simply: "Executable file could not be loaded in the debugger" I changed the Project Options to reference "main.exe" as the output... but nothing happens, the error continues... Juan ----- Original Message ----- From: "Jens Tusche" <Tu...@gm...> To: <dev...@li...> Sent: Thursday, January 22, 2004 2:02 PM Subject: [Dev-C++] (no subject) > <Hello, > <Finally, the source compiled Ok. But when I tried to use the debug > <feature of Dev-C++, the blue cursor doesn't appear in the code. I > <compiled the source with the "Generate debugging information" option, > <and the parameters -g and -gcoff in the compiler options, and doesn't do > <the job. > <Maybe there is a trick, or the like... > < > <Thanks in advance. > < > <Juan > > Hi I had the same problems with getting the debugger started, but then > someone advised me to put the parameter -g3 to the compiler options. Since then > it's been working. > > Jens > > -- > +++ GMX - die erste Adresse für Mail, Message, More +++ > Bis 31.1.: TopMail + Digicam für nur 29 EUR http://www.gmx.net/topmail > > > > ------------------------------------------------------- > The SF.Net email is sponsored by EclipseCon 2004 > Premiere Conference on Open Tools Development and Integration > See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. > http://www.eclipsecon.org/osdn > _______________________________________________ > 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: oladipo o. <ola...@ya...> - 2004-02-24 20:21:58
|
thanx, i received the reply, but i really dson't know how the whole thing works, i 'ld appreciate a concise tutorial on how the group works, and how i can benefit and add to the group thanks --------------------------------- Do you Yahoo!? Yahoo! Mail SpamGuard - Read only the mail you want. |
From: <cx...@vi...> - 2004-03-08 11:36:54
|
______________________________________ =================================================================== |
From: Erika B. <eri...@st...> - 2004-03-08 16:44:26
|
Hi guys! I have experienced a lot of problems programming with Dev-cpp 4.0; though, I continue to think that it is one of the most well-working application in order to program with C++ using Windows. So, I will make a list of my problems. First of all, I have some problems with the system of input/output. It seems that the program does not recognise cin >>...But it's probably my fault. This is the guilty program: #include <iostream.h> #include <stdio.h> #include <stdlib.h> #include <math.h> #include <complex.h> class Complesso { double re, im; /* le due componenti di un numero complesso*/ public: Complesso(); /* costruttore di default */ Complesso(double r, double i); /* costruttore con le due componenti */ Complesso operator+ (Complesso c); /* overloading di '+' per la somma fra numeri complessi */ Complesso operator-(Complesso d); /* overloading di '-' per la differenza fra numeri complessi */ Complesso operator*(Complesso e); /* overloading di '*' per il prodotto fra numeri complessi */ Complesso operator/(Complesso f); /* overloading di '/' per la divisione fra numeri complessi */ Complesso operator=(double re); double show(); }; /* fine dichiarazioni */ Complesso::Complesso() { re = 0; im = 0; } Complesso::Complesso(double r, double i) { re = r; im = i; } Complesso Complesso::operator+(Complesso c){ /* overloading di '+' per la somma fra numeri complessi */ Complesso a, b; c.re = a.re + b.re; c.im = a.im + b.im; return c; } Complesso Complesso::operator-(Complesso d){ /* overloading di '-' per la differenza fra numeri complessi */ Complesso a, b; d.re = a.re - b.re; d.im = a.im - b.im; return d; } Complesso Complesso::operator*(Complesso e){ /* overloading di '*' per il prodotto fra numeri complessi. NOTA: il prodotto del numero Complesso (a + ib) per il numero complesso (c + id) da' come risultato il numero complesso (ac-bd) + i(ad+bc) */ Complesso a, b; e.re = a.re*b.re - b.im*b.im; e.im = a.re*b.im + b.im*b.re; return e; } Complesso Complesso::operator/(Complesso f){ /* overloading di '/' per la divisione fra numeri complessi. NOTA: la divisione del numero complesso (a + ib) per il numero complesso (c + id) e' definita solo se almeno uno fra c e d e' diverso da 0. Il risultato e' il numero complesso (ac + bd)/(c^2+d^2)+ i (bc - ad)/(c^2+d^2) */ Complesso a, b; if (f.re!=0 || f.im!=0){ f.re = (a.re*b.re + a.im*b.im)/(a.re*b.re + b.im*b.im); f.im = (a.im*b.re - a.re*b.im)/(a.re*b.re + b.im*b.im); } return f; }; Complesso a, b, c, d, e, f; Complesso Complesso::operator=(double re) { c = c.re + c.im; return *this; } double Complesso::show() { printf("%lf, %lf"), c.re, c.im ; printf("c.re\n"); printf("c.im\n"); } int main() { cout <<"dammi a: ", cin >> (Complesso a); cout <<"\ndammi b: ", cin >> (Complesso b); c = a + b ; cout<< "la somma di a e b \350 c \n" ; c.show(); system("PAUSE"); return 0; } It is a classs that should do all the operstions between complex numbers, but it does'nt work very well. Dev-cpp doesn't show any fault, though. There is another version that works well on others pc, but on mine M_PI is not recognoised. Here it is: #include <iostream.h> #include <stdio.h> #include <math.h> class complex { double a[200], b[200], radice[2], somma[2], divisione[2], prodotto[2], x1[2], x2[2]; double x, y, z, t, p1, p2, p3, Delta, RAD, modulo, theta; int i, n, h; public: int Avvio(int r); int Importa(); int Somma(); int Prodotto(); int Divisione(); int Radice(); int Polinomio(); }; int complex::Avvio(int r) { switch(r) { case 1: {Somma(); break;} case 2: {Prodotto(); break;} case 3: {Divisione(); break;} case 4: {Radice(); break;} default: Polinomio(); } } int complex::Importa() { printf("\nQuanti numeri complessi vuoi usare max[200]? "); scanf("%d", &n); printf("\nInserisci i coefficienti dei %d numeri.\n", n); for (i=0; i<n; i++) { printf("\na%d: ", i); scanf("%lf", &a[i]); printf("b%d: ", i); scanf("%lf", &b[i]); } } int complex::Somma() { Importa(); somma[0]= a[0]; somma[1]= b[0]; for(i=1; i<n; i++) { somma[0]+= a[i]; somma[1]+= b[i]; } printf("\nSomma: %f", somma[0]); if (somma[1]>=0) printf("+%fi\n", somma[1]); else printf("%fi\n", somma[1]); } int complex::Prodotto() { Importa(); prodotto[0]= a[0]; prodotto[1]= b[0]; for(i=1; i<n; i++) { x= prodotto[0]* a[i]; y= prodotto[0]* b[i]; z= prodotto[1]* a[i]; t= prodotto[1]* b[i]; prodotto[0]= x - t; prodotto[1]= y + z; } printf("\nProdotto: %f", prodotto[0]); if (prodotto[1]>=0) printf("+%fi\n", prodotto[1]); else printf("%fi\n", prodotto[1]); } int complex::Divisione() { printf("\nScrivi i coefficienti dei due numeri della divisione:\n"); printf("\na0= "); scanf("%lf", &a[0]); printf("b0= "); scanf("%lf", &b[0]); printf("\na1= "); scanf("%lf", &a[1]); printf("b1= "); scanf("%lf", &b[1]); if(a[1]==0 && b[1]==0) printf("\nERRORE! DIVISIONE PER ZERO NON AMMESSA.\n"); else { divisione[0]=(a[0]*a[1] - b[0]*(-b[1]))/(a[1]*a[1] + b[1]*b[1]); divisione[1]=(a[0]*(-b[1]) + b[0]*a[1])/(a[1]*a[1] + b[1]*b[1]); printf("\nDivisione: %f", divisione[0]); if (divisione[1]>=0) printf("+%fi\n", divisione[1]); else printf("%fi\n", divisione[1]); } } int complex::Radice() { printf("\nScrivi i coefficenti [a,b] e l'indice [k] della radice:\n"); printf("\na= "); scanf("%lf", &a[0]); printf("b= "); scanf("%lf", &b[0]); printf("k= "); scanf("%d", &n); modulo=sqrt(a[0]*a[0] + b[0]*b[0]); theta=atan2(b[0],a[0]); x=pow(modulo,1./n); for(h=0; h<n; h++) { radice[0]=x*(cos((theta + 2*M_PI*h)/n)); radice[1]=x*(sin((theta + 2*M_PI*h)/n)); printf("\nZ(%d)= ", h); printf("%f", radice[0]); if (radice[1]>0) printf("+%fi\n", radice[1]); else printf("%fi\n", radice[1]); } } int complex::Polinomio() { printf("\nScrivi i coefficienti del polinomio\n"); printf("\na= "); scanf("%lf", &p1); printf("b= "); scanf("%lf", &p2); printf("c= "); scanf("%lf", &p3); Delta=(p2*p2) - (4*p1*p3); if (Delta>=0) { RAD= sqrt(Delta); x1[0]= (-p2 + RAD)/(2*p1); x2[0]= (-p2 - RAD)/(2*p1); printf("\nx1= %f", x1[0]); printf("\nx2= %f\n", x2[0]); } else { RAD= ((-1)*(Delta)); x1[0]= (-p2)/(2*p1); x1[1]= (RAD)/(2*p1); x2[0]= (-p2)/(2*p1); x2[1]= (-RAD)/(2*p1); printf("\nx1= %f", x1[0]); if (x1[1]>=0) printf("+%fi\n", x1[1]); else printf("%fi\n", x1[1]); printf("\nx2= %f", x2[0]); if (x2[1]>=0) printf("+%fi\n", x2[1]); else printf("%fi\n", x2[1]); } } int Richiesta() { int scelta; complex e; printf("\n[1] SOMMA di n numeri;"); printf("\n[2] PRODOTTO di n numeri;"); printf("\n[3] DIVISIONE tra 2 numeri;"); printf("\n[4] RADICE k-esima di un numero;"); printf("\n[5] RADICI di un polinomio di secondo grado;\n"); printf("\nNumero scelto: "); scanf("%d", &scelta); if(scelta<1 || scelta>5) { printf("\nERRORE!!! NUMERO NON AMMESSO\n"); Richiesta(); } else { e.Avvio(scelta); char c; printf("\nSE SI VUOLE ESEGUIRE UN ALTRO CALCOLO PREMERE [s]o [S]: "); scanf("%s", &c); if(c=='s' || c=='S') Richiesta(); } } int main() { printf("Questo programma esegue calcoli con i NUMERI COMPLESSI."); printf("\nDigita il numero indicato per utilizzare le varie operazioni:\n"); Richiesta(); } // But the most unexpecteded thing is in the last program: it works well on two others pcs, one has dev-cpp. It must give the factorial of a number, but when I execute it , it only returns the number followed by 0.000000... #include <stdio.h> #include <stdlib.h> long double l, n; int fattoriale (); int valori(); int funz(); int main() { printf("Scrivi il numero da fattorializzare: "); scanf("%Lf", &n); valori(); fattoriale(); funz(); system("PAUSE"); return 0; } int valori() { if((n>0) && (n<2000)) { l=n-1; fattoriale(); printf("Il fattoriale \350: %Le\n", n); } else if(n==0) printf ("Il fattoriale \350: 1\n"); else if(n<0) printf ("Non posso calcolare il fattoriale di un numero negativo\n"); else printf ("Non posso calcolare il fattoriale, il numero \350 troppo elevato\n"); funz(); } int fattoriale() { while(l>1) { n=n*l--; fattoriale(); } } int funz() { char c; printf ("Vuoi calcolare un altro fattoriale? Premere [s] o [S] se si: \n", c); scanf("%s", &c); if(c=='s'|| c=='S') main(); else printf ("Esecuzione terminata\n"); } And it worked well even with another C program. Now I will try to execute them with dev-cpp 5.0 because I think that it isn't only my fault and my loss of experience. Could you help me to find the bugs? Thank you Erika |
From: Per W. <pw...@ia...> - 2004-03-08 17:13:26
|
After a cursory glance, I have the following notes: 1) use <iostream> etc instead of <iostream.h> 2) specify "using std::cout" etc for things declared in header files without the .h extension. 3) the Complesso::show() method has the printf arguments AFTER closing parenthesis. You will get random numbers printed... 4) for efficiency, a program should not use printf() and std::cout at the same time, since the two output functions needs to perform flush() all the time to allow intermixed output. 5) your program should have: #ifndef M_PI #define M_PI 3.14159265358979323846 #endif 6) your funz() may NOT call main - you should nevery try to call main() yourself. It is only the startup code that may call main(). 7) when you implement factorial, you either do it as a loop, or as a recursive function taking the number as a parameter. Never create a mathematical function that takes it's parameter on the stack! /Per W On Mon, 8 Mar 2004, Erika Brattich wrote: > > > > > Hi guys! > I have experienced a lot of problems programming with Dev-cpp 4.0; though, I > continue to think that it is one of the most well-working application in order > to program with C++ using Windows. > So, I will make a list of my problems. > First of all, I have some problems with the system of input/output. It seems > that the program does not recognise cin >>...But it's probably my fault. > This is the guilty program: > > > #include <iostream.h> > #include <stdio.h> > #include <stdlib.h> > #include <math.h> > #include <complex.h> > > > > class Complesso > { > double re, im; /* le due componenti di un numero complesso*/ > > public: > Complesso(); /* costruttore di default */ > Complesso(double r, double i); /* costruttore con le due componenti */ > Complesso operator+ (Complesso c); /* overloading di '+' per la somma fra > numeri complessi */ > Complesso operator-(Complesso d); /* overloading di '-' per la differenza > fra numeri complessi */ > Complesso operator*(Complesso e); /* overloading di '*' per il prodotto fra > numeri complessi */ > Complesso operator/(Complesso f); /* overloading di '/' per la divisione fra > numeri complessi */ > Complesso operator=(double re); > double show(); > }; > /* fine dichiarazioni */ > > > > Complesso::Complesso() > { > re = 0; > im = 0; > } > > Complesso::Complesso(double r, double i) > { > re = r; > im = i; > } > > Complesso Complesso::operator+(Complesso c){ > /* overloading di '+' per la somma fra numeri complessi */ > Complesso a, b; > c.re = a.re + b.re; > c.im = a.im + b.im; > return c; > } > Complesso Complesso::operator-(Complesso d){ > /* overloading di '-' per la differenza fra numeri complessi */ > Complesso a, b; > d.re = a.re - b.re; > d.im = a.im - b.im; > return d; > } > Complesso Complesso::operator*(Complesso e){ > /* overloading di '*' per il prodotto fra numeri complessi. > NOTA: il prodotto del numero Complesso (a + ib) per il numero complesso > (c + id) da' come risultato il numero complesso > (ac-bd) + i(ad+bc) */ > Complesso a, b; > e.re = a.re*b.re - b.im*b.im; > e.im = a.re*b.im + b.im*b.re; > return e; > } > Complesso Complesso::operator/(Complesso f){ > /* overloading di '/' per la divisione fra numeri complessi. > NOTA: la divisione del numero complesso (a + ib) per il numero complesso > (c + id) e' definita solo se almeno uno fra c e d e' diverso da 0. > Il risultato e' il numero complesso > (ac + bd)/(c^2+d^2)+ i (bc - ad)/(c^2+d^2) */ > > Complesso a, b; > if (f.re!=0 || f.im!=0){ > f.re = (a.re*b.re + a.im*b.im)/(a.re*b.re + b.im*b.im); > f.im = (a.im*b.re - a.re*b.im)/(a.re*b.re + b.im*b.im); > } > return f; > }; > Complesso a, b, c, d, e, f; > > Complesso Complesso::operator=(double re) > { > c = c.re + c.im; > return *this; > } > double Complesso::show() > { > printf("%lf, %lf"), c.re, c.im ; > printf("c.re\n"); > printf("c.im\n"); > > } > > > int main() > { > cout <<"dammi a: ", cin >> (Complesso a); > cout <<"\ndammi b: ", cin >> (Complesso b); > c = a + b ; > cout<< "la somma di a e b \350 c \n" ; > c.show(); > system("PAUSE"); > return 0; > } > > It is a classs that should do all the operstions between complex numbers, but > it does'nt work very well. > Dev-cpp doesn't show any fault, though. > > There is another version that works well on others pc, but on mine M_PI is not > recognoised. Here it is: > > #include <iostream.h> > #include <stdio.h> > #include <math.h> > > class complex > { > double a[200], b[200], radice[2], somma[2], divisione[2], prodotto[2], x1[2], > x2[2]; > double x, y, z, t, p1, p2, p3, Delta, RAD, modulo, theta; > int i, n, h; > > public: > > int Avvio(int r); > int Importa(); > int Somma(); > int Prodotto(); > int Divisione(); > int Radice(); > int Polinomio(); > }; > > int complex::Avvio(int r) > { > switch(r) > { > case 1: {Somma(); break;} > case 2: {Prodotto(); break;} > case 3: {Divisione(); break;} > case 4: {Radice(); break;} > default: Polinomio(); > } > } > > int complex::Importa() > { > printf("\nQuanti numeri complessi vuoi usare max[200]? "); > scanf("%d", &n); > > printf("\nInserisci i coefficienti dei %d numeri.\n", n); > > for (i=0; i<n; i++) > { > printf("\na%d: ", i); > scanf("%lf", &a[i]); > printf("b%d: ", i); > scanf("%lf", &b[i]); > } > } > > int complex::Somma() > { > Importa(); > > somma[0]= a[0]; > somma[1]= b[0]; > > for(i=1; i<n; i++) > { > somma[0]+= a[i]; > somma[1]+= b[i]; > } > > printf("\nSomma: %f", somma[0]); > if (somma[1]>=0) printf("+%fi\n", somma[1]); > else printf("%fi\n", somma[1]); > } > > int complex::Prodotto() > { > Importa(); > > prodotto[0]= a[0]; > prodotto[1]= b[0]; > > for(i=1; i<n; i++) > { > x= prodotto[0]* a[i]; > y= prodotto[0]* b[i]; > z= prodotto[1]* a[i]; > t= prodotto[1]* b[i]; > > prodotto[0]= x - t; > prodotto[1]= y + z; > } > > printf("\nProdotto: %f", prodotto[0]); > if (prodotto[1]>=0) printf("+%fi\n", prodotto[1]); > else printf("%fi\n", prodotto[1]); > } > > int complex::Divisione() > { > printf("\nScrivi i coefficienti dei due numeri della divisione:\n"); > printf("\na0= "); > scanf("%lf", &a[0]); > printf("b0= "); > scanf("%lf", &b[0]); > printf("\na1= "); > scanf("%lf", &a[1]); > printf("b1= "); > scanf("%lf", &b[1]); > > if(a[1]==0 && b[1]==0) printf("\nERRORE! DIVISIONE PER ZERO NON AMMESSA.\n"); > else > { > > divisione[0]=(a[0]*a[1] - b[0]*(-b[1]))/(a[1]*a[1] + b[1]*b[1]); > divisione[1]=(a[0]*(-b[1]) + b[0]*a[1])/(a[1]*a[1] + b[1]*b[1]); > > printf("\nDivisione: %f", divisione[0]); > if (divisione[1]>=0) printf("+%fi\n", divisione[1]); > else printf("%fi\n", divisione[1]); > } > } > > int complex::Radice() > { > printf("\nScrivi i coefficenti [a,b] e l'indice [k] della radice:\n"); > > printf("\na= "); > scanf("%lf", &a[0]); > printf("b= "); > scanf("%lf", &b[0]); > printf("k= "); > scanf("%d", &n); > > modulo=sqrt(a[0]*a[0] + b[0]*b[0]); > theta=atan2(b[0],a[0]); > x=pow(modulo,1./n); > > for(h=0; h<n; h++) > { > radice[0]=x*(cos((theta + 2*M_PI*h)/n)); > radice[1]=x*(sin((theta + 2*M_PI*h)/n)); > > printf("\nZ(%d)= ", h); printf("%f", radice[0]); > if (radice[1]>0) printf("+%fi\n", radice[1]); > else printf("%fi\n", radice[1]); > } > } > > int complex::Polinomio() > { > printf("\nScrivi i coefficienti del polinomio\n"); > printf("\na= "); > scanf("%lf", &p1); > printf("b= "); > scanf("%lf", &p2); > printf("c= "); > scanf("%lf", &p3); > > Delta=(p2*p2) - (4*p1*p3); > > if (Delta>=0) > { > RAD= sqrt(Delta); > x1[0]= (-p2 + RAD)/(2*p1); > x2[0]= (-p2 - RAD)/(2*p1); > > printf("\nx1= %f", x1[0]); > printf("\nx2= %f\n", x2[0]); > } > > else > { > RAD= ((-1)*(Delta)); > > x1[0]= (-p2)/(2*p1); > x1[1]= (RAD)/(2*p1); > x2[0]= (-p2)/(2*p1); > x2[1]= (-RAD)/(2*p1); > > printf("\nx1= %f", x1[0]); > if (x1[1]>=0) printf("+%fi\n", x1[1]); > else printf("%fi\n", x1[1]); > > printf("\nx2= %f", x2[0]); > if (x2[1]>=0) printf("+%fi\n", x2[1]); > else printf("%fi\n", x2[1]); > } > } > > int Richiesta() > { > int scelta; > complex e; > > printf("\n[1] SOMMA di n numeri;"); > printf("\n[2] PRODOTTO di n numeri;"); > printf("\n[3] DIVISIONE tra 2 numeri;"); > printf("\n[4] RADICE k-esima di un numero;"); > printf("\n[5] RADICI di un polinomio di secondo grado;\n"); > > printf("\nNumero scelto: "); > scanf("%d", &scelta); > if(scelta<1 || scelta>5) > { > printf("\nERRORE!!! NUMERO NON AMMESSO\n"); > Richiesta(); > } > else > { > e.Avvio(scelta); > > char c; > printf("\nSE SI VUOLE ESEGUIRE UN ALTRO CALCOLO PREMERE [s]o [S]: "); > scanf("%s", &c); > if(c=='s' || c=='S') Richiesta(); > } > } > > int main() > { > printf("Questo programma esegue calcoli con i NUMERI COMPLESSI."); > printf("\nDigita il numero indicato per utilizzare le varie operazioni:\n"); > > Richiesta(); > } // > > > But the most unexpecteded thing is in the last program: it works well on two > others pcs, one has dev-cpp. It must give the factorial of a number, but when I > execute it , it only returns the number followed by 0.000000... > #include <stdio.h> > #include <stdlib.h> > > long double l, n; > > int fattoriale (); > int valori(); > int funz(); > > int main() > { > printf("Scrivi il numero da fattorializzare: "); > scanf("%Lf", &n); > > valori(); > fattoriale(); > funz(); > system("PAUSE"); > return 0; > } > > int valori() > { > if((n>0) && (n<2000)) > { > l=n-1; > fattoriale(); > printf("Il fattoriale \350: %Le\n", n); > } > else if(n==0) printf ("Il fattoriale \350: 1\n"); > else if(n<0) printf ("Non posso calcolare il fattoriale di un numero > negativo\n"); > else printf ("Non posso calcolare il fattoriale, il numero \350 troppo > elevato\n"); > funz(); > } > > int fattoriale() > { > while(l>1) > { > n=n*l--; > fattoriale(); > } > } > > int funz() > { > char c; > printf ("Vuoi calcolare un altro fattoriale? Premere [s] o [S] se si: \n", c); > scanf("%s", &c); > if(c=='s'|| c=='S') main(); > else printf ("Esecuzione terminata\n"); > } > > And it worked well even with another C program. Now I will try to execute them > with dev-cpp 5.0 because I think that it isn't only my fault and my loss of > experience. Could you help me to find the bugs? > > Thank you > > Erika > > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IBM Linux Tutorials > Free Linux tutorial presented by Daniel Robbins, President and CEO of > GenToo technologies. Learn everything from fundamentals to system > administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click > _______________________________________________ > 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: mikro <mi...@te...> - 2004-03-10 16:23:40
|
From: <cm...@ya...> - 2004-03-14 18:13:16
|
Hello Im newbie on c and c++ and Im also learning java and I wanted to make a web page with a friend and I wanted to make a visit counter(or is it hit counter?), anyway I wanted to ask you if I could make this in C++ and If you knew where to get some help of the subject. Thanks Claudio Veas Excuse my english is not so good as it used to be ------------ Los mejores usados y las más tentadoras ofertas de 0km están en Yahoo! Autos. Comprá o vendé tu auto en http://autos.yahoo.com.ar |
From: Tim S. <ti...@we...> - 2004-03-15 02:14:56
|
Hi Claudio, you wrote, > anyway I wanted to ask you if I could make this in C++ of course you can do and its realy simple, all you need is a cgi-bin directory from your webhosting provider put your programm in this dir and set it executeable. Since most internet- provider have linux servers you need to compile it under linux, if you don't have installed linux and dont want to you can try Knoppix, a distribution which can be booted from CD, the URL where you can download a image is www.knopper.net. For programming an CGI there is a nice tutorial at http://www.coding-zone.co.uk/cpp/cgi/170401cgicpp.shtml hth Tim -- > Und wer als Root browst, gehoert eh | http://we-are-teh-b.org/~tim/borg.key > in Honig getunkt, in Wollfaeden gewaelzt | http://learn.to/quote > und im Streichelzoo ausgesetzt... | http://discworld.kicks-ass.org rockshop auf heise.de |
From: <gen...@ya...> - 2004-03-25 11:03:20
|
hope siteresources won't flood the list seeing he's from floodcity :D anyhow, i think the problem is he didn't include windows.h in his resource file. correct me if i'm wrong. besides, he's not told us EXACTLY what went wrong. cheers ___________________________________________________________ Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now http://uk.messenger.yahoo.com/download/index.html |
From: Site R. <sit...@fl...> - 2004-03-25 11:14:18
|
I've never seen anyone include windows.h in a resource file before. It = doesn't use anything from windows.h anyway. lol I did tell you what went wrong, at the bottom of my email, I gave = the exact error I got. That's all th einformation Ihave about what went = wrong. Brandon |