ParsX.com
پذیرش پروژه از دانشجویی ... تا سازمانی 09376225339
 
   ProfileProfile   Log in to check your private messagesLog in to check your private messages  |  FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups Log inLog in   RegisterRegister 

چند جمله اي

 
Post new topic   Reply to topic    ParsX.com Forum Index -> اصول ساختمان داده ها
View previous topic :: View next topic  
Author Message
elinaz
مهمون يكي دو روزه


Joined: 21 Nov 2007
Posts: 42
Location: تهران

PostPosted: Tue Dec 11, 2007 3:32 pm    Post subject: چند جمله اي Reply with quote

- برنامه که دو چند جمله ای بگیرد و با یکدیگر جمع نماید و حاصل را در خرروجی چاپ نماید . چند جمله ای اول چند متغیر x دارد و بعد ضرایب x را به تر تیب از توان بزرگ به کوچک و عدد ثابت که همان توان 0 بگیرد و برای جمله دیگر نیز به همین ترتیب



#include<iostream.h>
#include<conio.h>
void addup(int,int);
int *arr1,*arr2,power1,power2;
void main()
{
clrscr();
cout<<"Khosh Omadid ..."<<endl;
cout<<"Bozorg tarin tavane jomleye aval ?\n";
cin>>power1;
cout<<"Bozorg tarin tavane jomleye dovom ?\n";
cin>>power2;
addup(power1,power2);
getch();
}
void addup(int pw1,int pw2)
{
int *arr1,*arr2,*result,i,temp;
arr1= new int[pw1+1];
arr2=new int[pw2+1];
for (i=pw1;i>=0;i--)
{
cout<<"Jomleye aval :: Zaribe X ba tavane "<<i<<"ra vared konid"<<endl;
cin>>arr1[i];
}//end of 1st for
for (i=pw2;i>=0;i--)
{
cout<<"Jomleye dovom :: Zaribe X ba tavane "<<i<<"ra vared konid"<<endl;
cin>>arr2[i];
}//end of 2nd for
result=new int( pw1>=pw2 ? pw1 : pw2 );
for (i=( pw1>=pw2 ? pw1 : pw2 );i>=0;i--)
{
result[i]=0;
/* chon daram ba meghdare ghabli jam mikonam age meghdar dehiye avaliye ( 0 ) nashe moshkeli
pish miad, meghdare ghabli ke to on noghte az hafeze boode ro bahash jam mikone */
if (i<=pw1)
result[i]+=arr1[i];
if (i<=pw2)
result[i]+=arr2[i];
}//end of for
/*chap kardane natije ( result )*/
for (i=( pw1>=pw2 ? pw1 : pw2 );i>=0;i--)
{
cout<<result[i]<<"X^"<<i;
if (i!=0)
cout<<" + ";
}
}//end of Function addup


لطفا علامتها را بر عكس كن

****************************************

خدايا مومنم به اينكه هر كس به تو توكل كند شكست نمي خورد
Back to top
Malake
مهمون يكي دو روزه


Joined: 05 Dec 2007
Posts: 17

PostPosted: Wed Dec 12, 2007 2:19 pm    Post subject: Reply with quote

salam ....kheili kheili mamnon az lotfetoooooon,,,,,,,,,,,,,,,,,,, Very Happy
Back to top
Display posts from previous:   
Post new topic   Reply to topic    ParsX.com Forum Index -> اصول ساختمان داده ها All times are GMT + 3.5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum