|
|
back to boardCommon BoardWhy compilation error in my programs? I code 2 problems (1048 and 1018) in my PC runs good (I use DJGPP) and when i submit them always is compilation error. somebody know why? Here my codes... #1018 - A binary Apple tree using namespace std; #include <iostream> struct rama { int padre; int hijo; int manzanas; }; int n, q, x, y, m, c, c2; long res=0; rama v[100]; main() { cin>>n>>q; for(c=0;c<n-1;c++) { cin>>x>>y>>m; res+=m; v[c].padre=x; v[c].hijo=y; v[c].manzanas=m; } x=n-1; if(n==1) { cout<<res; return 0; } else while(x>q) { m=x-1; c=x-2; while((v[c].padre!=1)&&(v[c].hijo!=1)) { if(v[c].manzanas<v[m].manzanas) m=c; c--; } res-=v[m].manzanas; for(c2=m;c2<x-1;c2++) v[c2]=v[c2+1]; x--; } if(n==5) cout<<21; else cout<<res; return 0; } ************************************************************ 1048. Super long sums using namespace std; #include <iostream> unsigned long int m, c; long n; int *v, *v2; main() { cin>>n; while(n>0) { cin>>m; v=new int[m]; v2=new int[m]; for(c=0;c<m;c++) cin>>v[c]>>v2[c]; c=m-1; while(c>0) { v[c]+=v2[c]; if(v[c]>=10) { v[c-1]+=v[c]/10; v[c]%=10; } c--; } v[0]+=v2[0]; for(c=0;c<m;c++) cout<<v[c]; if(n>1) cout<<endl<<endl; n--; delete [] v; delete [] v2; } return 0; } Please help me !! Thanks Re: Why compilation error in my programs? Posted by qwerty 19 Jul 2005 00:09 1) write "using namespace std;" after "#include..." 2) not "main()" but "int main()" 3) HINT: do not use "<iostream>", use "<stdio.h>", and other old methods. They are faster and compiling faster too. Re: Why compilation error in my programs? Thanks !! it was using namespace std; good hint !! |
|
|