PDA

نسخه کامل مشاهده نسخه کامل : تبدیل turbo c++ به C++ ?!



mohammadT.M
07-01-2010, 20:29
من 1 برنامه به زبان turbo c++ دارم
میخوام ببینم میشه کدهاشو توی C++ اجرا کرد ؟! یا باید تغیرات بدم توش
اصلا باید چیکارش کنم ؟!
راستی من زیاد برنامه نویسی کار نکردم ( فقط 1 کم )

p d
07-01-2010, 21:34
انچنان فرقي نداره؟
قديمي تر ها std رو نميشناسن جاش از .h استفاده ميشه.
و براي بعضي ها لازم در اخر براي جلوگيري از بسته شدن پنجره كه حروجي رو نشون ميده از getch() استفاده كرد.
سورس رو بذار.
از چي استفاده ميكني ؟

mohammadT.M
08-01-2010, 03:13
اگه اینو به C++‌برگردونی خیلی ممنون میشم :11:


#include <iostream.h>
#include <conio.h>
#include <iomanip>
#include <vcl.h>
int main(){
int i,j,k,s,p;
char input='\0';
int cost[13],incom[12],netincom[12],tcost=0,tincom=0,tnetincom=0;
int costmax=0,incommax=0,netincommax;
int year=0,mounth=0,day=0;
cout<<"Enter Command"<<'\n';
for(i=1;i<=12;i++){
cost[i]=0;
netincom[i]=0;
incom[i]=0;
}

while(input!='*'){
cout<<"Cost-Exit-Incom-Maximum(C/E/I/M)"<<'\n';
cin>>input;

if (input=='c'){
cout<<"total cost is "<<tcost<<"\n";
cout<<"insert new cost"<<'\n';
cout<<"insert date"<<'\n';
cout<<"day= ";
cin>>day;


cout<<"mounth=";
cin>>mounth;
cout<<"year=";
cin>>year;
cout<<"cost=";
cin>>cost[mounth];
tcost=tcost+cost[mounth];
tnetincom=tnetincom-cost[mounth];
netincom[mounth]=netincom[mounth]-cost[mounth];
cout<<'\n'<<'\n';
} //end if//


else if(input=='i'){
cout<<"total incom is "<<tincom<<'\n';;
cout<<"insert new incom"<<'\n';
cout<<"insert date"<<'\n';
cout<<"day= ";
cin>>day;
cout<<"mounth=";
cin>>mounth;
cout<<"year= ";
cin>>year;
cout<<"incom= ";
cin>>incom[mounth];
tincom=tincom+incom[mounth];
tnetincom=tnetincom+incom[mounth];
netincom[mounth]=netincom[mounth]+incom[mounth];
cout<<'\n'<<'\n';
} //end incom//




else if(input=='m'){
for(j=1;j<=12;j++){
if (cost[j]>costmax)
costmax=cost[j];

if (incom[j]>incommax)
incommax=incom[j];
if (netincom[j]>netincommax)
netincommax=netincom[j];
} //end for//
cout<<"netincommax= "<<netincommax<<'\n';
cout<<"incommax= "<<incommax<<'\n';
cout<<"costmax= "<<costmax<<'\n';
cout<<'\n';
} //end if//



else if(input=='e'){

cout<<" "<<"YERLY REPORT"<<'\n';
cout<<"Month Incom Cost Netincome"<<'\n';
cout<<"--------------------------------------------------------------------"<<'\n';
for(k=1;k<=12;k++)
cout<<setw(2)<<k<<" "<<incom[k]<<" "<<cost[k]<<" "<<netincom[k]<<'\n';
cout<<"--------------------------------------------------------------------"<<'\n';
cout<<"Total"<<" "<<tincom<<" "<<tcost<<" "<<tnetincom<<'\n'<<'\n';

break ;

}//end if//

else if(input!='c'||input!='e'||input!='i'||input!='m')
cout<<"the charechter is not avalable pleas try again"<<'\n'<<'\n';
if (cost[1]+cost[2]+cost[3]>10000000){
cout<<"hazine bahar bishtar az hade mojaz ast"<<'\n';
cost[1]=cost[2]=cost[3]=0;
}
if (cost[4]+cost[5]+cost[6]>10000000){
cost[4]=cost[5]=cost[6]=0;
cout<<"hazine tabestan bishtar az hade mojaz ast"<<'\n' ;
}
if (cost[7]+cost[8]+cost[9]>10000000){
cost[7]=cost[8]=cost[9]=0;
cout<<"hazine paeez bishtar az hade mojaz ast"<<'\n' ;
}
if (cost[10]+cost[11]+cost[12]>10000000){
cost[10]=cost[11]=cost[12]=0;
cout<<"hazine zemestan bishtar az hade mojaz ast"<<'\n';
}

if (incom[1]+incom[2]+incom[3]>100000000){
cout<<"daramad bahar bishtar az hade mojaz ast"<<'\n';
cost[1]=cost[2]=cost[3]=0;
}
if (incom[4]+incom[5]+incom[6]>100000000){
incom[4]=incom[5]=incom[6]=0;
cout<<"daramad tabestan bishtar az hade mojaz ast"<<'\n' ;
}
if (incom[7]+incom[8]+incom[9]>100000000) {
cost[7]=cost[8]=cost[9]=0;
cout<<"daramad paeez bishtar az hade mojaz ast"<<'\n' ;
}
if (incom[10]+incom[11]+incom[12]>100000000){
incom[10]=incom[11]=incom[12]=0;
cout<<"daramad zemestan bishtar az hade mojaz ast"<<'\n';
}
} //end while//
getch();
return 0;
} //end main//

p d
08-01-2010, 09:41
در خواستتون صحيح نيست!:20:
يعني چي به c++ برگردون ؟؟؟؟ اين خودش c++ هست .
در ضمن همون طوري كه گفتم با كامپايلر قديمي نوشته شده. مثلا توربو.
اگه ميخواي كاري كني كه تويه كامپايلر جديد اجرا بشه , همين هم ميشه .
يا بهتره getch(); رو حذف كني يا بجاي .h در iostream از using namespace std استفاده كني
البته لزومي نداره.

mohammadT.M
08-01-2010, 14:20
دوست عزیز ممنون که جواب میدید
ولی من هنوز مشکل دارم

اینو که کپی میکنم ارور میده
میشه شما آمادش کنید ببینید اشکالش چیه ؟!

ممنون



#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <iomanip>
#include <vcl.h>

int _tmain(int argc, _TCHAR* argv[])
{

int i,j,k,s,p;
char input='\0';
int cost[13],incom[12],netincom[12],tcost=0,tincom=0,tnetincom=0;
int costmax=0,incommax=0,netincommax;
int year=0,mounth=0,day=0;
cout<<"Enter Command"<<'\n';
for(i=1;i<=12;i++){
cost[i]=0;
netincom[i]=0;
incom[i]=0;
}

while(input!='*'){
cout<<"Cost-Exit-Incom-Maximum(C/E/I/M)"<<'\n';
cin>>input;

if (input=='c'){
cout<<"total cost is "<<tcost<<"\n";
cout<<"insert new cost"<<'\n';
cout<<"insert date"<<'\n';
cout<<"day= ";
cin>>day;


cout<<"mounth=";
cin>>mounth;
cout<<"year=";
cin>>year;
cout<<"cost=";
cin>>cost[mounth];
tcost=tcost+cost[mounth];
tnetincom=tnetincom-cost[mounth];
netincom[mounth]=netincom[mounth]-cost[mounth];
cout<<'\n'<<'\n';
} //end if//


else if(input=='i'){
cout<<"total incom is "<<tincom<<'\n';;
cout<<"insert new incom"<<'\n';
cout<<"insert date"<<'\n';
cout<<"day= ";
cin>>day;
cout<<"mounth=";
cin>>mounth;
cout<<"year= ";
cin>>year;
cout<<"incom= ";
cin>>incom[mounth];
tincom=tincom+incom[mounth];
tnetincom=tnetincom+incom[mounth];
netincom[mounth]=netincom[mounth]+incom[mounth];
cout<<'\n'<<'\n';
} //end incom//




else if(input=='m'){
for(j=1;j<=12;j++){
if (cost[j]>costmax)
costmax=cost[j];

if (incom[j]>incommax)
incommax=incom[j];
if (netincom[j]>netincommax)
netincommax=netincom[j];
} //end for//
cout<<"netincommax= "<<netincommax<<'\n';
cout<<"incommax= "<<incommax<<'\n';
cout<<"costmax= "<<costmax<<'\n';
cout<<'\n';
} //end if//



else if(input=='e'){

cout<<" "<<"YERLY REPORT"<<'\n';
cout<<"Month Incom Cost Netincome"<<'\n';
cout<<"--------------------------------------------------------------------"<<'\n';
for(k=1;k<=12;k++)
cout<<setw(2)<<k<<" "<<incom[k]<<" "<<cost[k]<<" "<<netincom[k]<<'\n';
cout<<"--------------------------------------------------------------------"<<'\n';
cout<<"Total"<<" "<<tincom<<" "<<tcost<<" "<<tnetincom<<'\n'<<'\n';

break ;

}//end if//

else if(input!='c'||input!='e'||input!='i'||input!='m')
cout<<"the charechter is not avalable pleas try again"<<'\n'<<'\n';
if (cost[1]+cost[2]+cost[3]>10000000){
cout<<"hazine bahar bishtar az hade mojaz ast"<<'\n';
cost[1]=cost[2]=cost[3]=0;
}
if (cost[4]+cost[5]+cost[6]>10000000){
cost[4]=cost[5]=cost[6]=0;
cout<<"hazine tabestan bishtar az hade mojaz ast"<<'\n' ;
}
if (cost[7]+cost[8]+cost[9]>10000000){
cost[7]=cost[8]=cost[9]=0;
cout<<"hazine paeez bishtar az hade mojaz ast"<<'\n' ;
}
if (cost[10]+cost[11]+cost[12]>10000000){
cost[10]=cost[11]=cost[12]=0;
cout<<"hazine zemestan bishtar az hade mojaz ast"<<'\n';
}

if (incom[1]+incom[2]+incom[3]>100000000){
cout<<"daramad bahar bishtar az hade mojaz ast"<<'\n';
cost[1]=cost[2]=cost[3]=0;
}
if (incom[4]+incom[5]+incom[6]>100000000){
incom[4]=incom[5]=incom[6]=0;
cout<<"daramad tabestan bishtar az hade mojaz ast"<<'\n' ;
}
if (incom[7]+incom[8]+incom[9]>100000000) {
cost[7]=cost[8]=cost[9]=0;
cout<<"daramad paeez bishtar az hade mojaz ast"<<'\n' ;
}
if (incom[10]+incom[11]+incom[12]>100000000){
incom[10]=incom[11]=incom[12]=0;
cout<<"daramad zemestan bishtar az hade mojaz ast"<<'\n';
}
} //end while//
return 0;
} //end main//

p d
08-01-2010, 17:43
:11:
از اين بيد :

برای مشاهده محتوا ، لطفا وارد شوید یا ثبت نام کنیداين يه include هست كه توسط برنامه نويس نوشته شده .
بايد اين قسمت كد رو هم داشته باشيد, كه جداست.
اگه تازه كاري اين سورس مناسب شروع نيست.
برو دنباله سورس هاي ساده تر. از اون بهتر اين كه خودت برنامه بنويس.
تويه همين تالار پر از سورس هست

gmuosavi
08-01-2010, 18:27
:11:
از اين بيد :

برای مشاهده محتوا ، لطفا وارد شوید یا ثبت نام کنیداين يه include هست كه توسط برنامه نويس نوشته شده .
بايد اين قسمت كد رو هم داشته باشيد, كه جداست.
اگه تازه كاري اين سورس مناسب شروع نيست.
برو دنباله سورس هاي ساده تر. از اون بهتر اين كه خودت برنامه بنويس.
تويه همين تالار پر از سورس هست

این رو که خود برنامه بطور پیشفرض داره !
اگه شما لطف کنید کد صحیح رو بنویسید بهش بدید تا کار این بنده خدا هم حل بشه :10:

راستی من این کد رو اجرا کردم ارورش این بود :


برای مشاهده محتوا ، لطفا وارد شوید یا ثبت نام کنید

sin2x=2sinxcosx
08-01-2010, 20:43
هدری با نام vcl نداریم. ولی vcclr داریم .

p d
08-01-2010, 20:52
اين رو ببين:



برای مشاهده محتوا ، لطفا وارد شوید یا ثبت نام کنید
برای مشاهده محتوا ، لطفا وارد شوید یا ثبت نام کنید


سه تا error ميده.
يكيش vcl هست كه sin گفت.
ديگري stdafx هست كه لينك ها رو ببين.

mohammadT.M
08-01-2010, 21:41
vcl رو به vcclr تغییر دادم
ممنون
:10:
ولی همچنان اشکال داره

از اون دوتا لینک هم چیزی نفهمیدم ! :41:

hoax3r
08-01-2010, 22:26
کدهای قبل از main رو به اینی که پایین گزاشتم تغییر بده، موقع ساخت پروژه هم گزینه Empty project رو بزن

برای مشاهده محتوا ، لطفا وارد شوید یا ثبت نام کنید

من با همین تغییران کامپایل کردم

mohammadT.M
09-01-2010, 14:20
باز هم حل نشد :41:

sin2x=2sinxcosx
09-01-2010, 15:41
خب مشکلتون چیه ؟ شما که نگفتین منظورتون از تبدیل ++Turbo C به ++C چی هست ؟ تو برنامه نویسی یه همچین جمله ای مفهوم نداره .

mohammadT.M
09-01-2010, 16:08
من فقط 1 چیز میخوام
این کدی که دادم رو بتونم توی c++ اجرا کنم
این کارهایی هم که تا الان کفتید رو انجام دادم ولی برنامه اشکال داره

یعنی 1 نفر نیست این کد رو دوباره بنویسه و برام بذاره ؟!

ممنون

sin2x=2sinxcosx
09-01-2010, 18:05
ای بابا . باز میگه به ++C تبدیل کن . بفرما . این کد رو امتحان کن :

برای مشاهده محتوا ، لطفا وارد شوید یا ثبت نام کنید