PDA

View Full Version : سوال: تبدیل کد C++ به C



xminxmin
شنبه 28 خرداد 1390, 07:55 صبح
دوستان سلام
یه کد به سی پلاس پلاس هست که می خوام تبدیل بشه به سی.
من وی بی کار هستم و از C سر در نمیارم
ممنونتون می شم اگر کمکم کنید:قلب:



#include<iostream.h>
#include<conio.h>
void Enco()
{
cout<<endl<<"---------------------"<<endl;
char str[100];
cout<<"please enter a sentence:"<<endl;
cin>>str;
cout<<"The code is:"<<endl;
int a=0;
while(str[a]!='\0')
{
if((str[a]-49)<10)
cout<<"0"<<int (str[a]-49);
else
cout<<int (str[a]-49);
a++;
}
cout<<endl<<"---------------------"<<endl;
}

void Deco()
{
cout<<endl<<"---------------------"<<endl;
char str[100];
int ch=0;
cout<<"please enter the code:"<<endl;
cin>>str;
cout<<"The Text is:"<<endl;
int a=2;
while (str[a-2]!='\0')
{
ch=((str[a-2]-48)*10)+((str[a-1]-48)*1)+49;
cout<<char (ch);
a+=2;
}
cout<<endl<<"---------------------"<<endl;
}

void main()
{
clrscr();
cout<<"Welcome,Please Select a method:"<<endl<<"1.String"<<endl<<"2.Inteager"<<endl<<"3.Exit"<<endl;
int a1=0;
while((cin>>a1)&&a1!=3)
{
if(a1==1)
Enco();
else if(a1==2)
Deco();
else
cout<<endl<<"Error,Select Again!"<<endl;

cout<<"Welcome,Please Select a method:"<<endl<<"1.Encode"<<endl<<"2.Decode"<<endl<<"3.Exit"<<endl;
}
}