infoarena

Comunitate - feedback, proiecte si distractie => Feedback infoarena => Subiect creat de: A Cosmina - vechi din Aprilie 12, 2009, 14:48:55



Titlul: Suma divizorilor
Scris de: A Cosmina - vechi din Aprilie 12, 2009, 14:48:55
Salut! :) Am rezolvat si eu o problema pe forum si nu inteleg de ce imi afiseaza eroare de compilare.La mine pe calculator functioneaza perfect! As avea nevoie de niste lamuriri, verau sa castig si eu puncte.

Aceasta este sursa:
Cod:
#include <fstream.h>   
#include <conio.h>   
#include <math.h>   
int main()   
{   
clrscr();   
fstream f("sumdiv.in",ios::in),g("sumdiv.out",ios::out);   
int a,b,s=0,i,r=0,p=0;   
f>>a>>b;   
p=pow(a,b);   
for (i=1;i<=p;i++)   
if ( p%i==0) s+=i;   
r=s%9901;   
g<<r;   
f.close();   
g.close();   
return 0;   
}   

Iar acestea erorile:

Citat
Eroare de compilare:
In file included from /usr/include/c++/4.2/backward/fstream.h:31,
                 from user.cpp:1:
/usr/include/c++/4.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
user.cpp:2:19: error: conio.h: No such file or directory
user.cpp: In function 'int main()':
user.cpp:6: error: 'clrscr' was not declared in this scope
user.cpp:7: error: 'ios' has not been declared
user.cpp:7: error: 'ios' has not been declared


Titlul: Răspuns: Suma divizorilor
Scris de: Andrei Misarca din Aprilie 12, 2009, 14:56:19
clrscr nu este recunoscuta de compilator(de altfel nici nu inteleg de ce o folosesti), iar cand deschizi fisierele foloseste ifstream si ofstream :)


Titlul: Răspuns: Suma divizorilor
Scris de: A Cosmina - vechi din Aprilie 12, 2009, 15:00:19
adica ceva de genul asta:

Cod:
istream f("sumdiv.un");
ofstream g("sumdiv.out");

asta-i tot? pot sa o pun din nou?


Titlul: Răspuns: Suma divizorilor
Scris de: Andrei Grigorean din Aprilie 12, 2009, 16:22:15
Poti sa o pui din nou, dar ai grija sa nu incluzi conio.h


Titlul: Răspuns: Suma divizorilor
Scris de: A Cosmina - vechi din Aprilie 12, 2009, 16:32:02
Eroare de compilare:
In file included from /usr/include/c++/4.2/backward/fstream.h:31,
                 from user.cpp:1:
/usr/include/c++/4.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
user.cpp: In function 'int main()':
user.cpp:5: error: 'ios' has not been declared
user.cpp:5: error: 'ios' has not been declared
   


Titlul: Răspuns: Suma divizorilor
Scris de: Paul-Dan Baltescu din Aprilie 13, 2009, 09:57:25
Include librariile <iostream> si <fstream> (fara .h) si adauga "using namespace std;" (inainte de int main() undeva).


Titlul: Răspuns: Suma divizorilor
Scris de: A Cosmina - vechi din Aprilie 13, 2009, 10:02:44
si <math.h> ramane cu h?
in compilator nu-mi accepta <iostream> si <fstream>  ???


Titlul: Răspuns: Suma divizorilor
Scris de: Paul-Dan Baltescu din Aprilie 13, 2009, 10:12:58
Lucrezi in Borland C?


Titlul: Răspuns: Suma divizorilor
Scris de: A Cosmina - vechi din Aprilie 13, 2009, 10:19:12
da, am inlocuit fstream f("sumdiv.in",ios::in) etc...
cu ifstream si ofstream. sa vad daca merge

edit:

Citat
Compilare:
In file included from /usr/include/c++/4.2/backward/fstream.h:31,
                 from user.cpp:1:
/usr/include/c++/4.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.