برای سوال 2نقل قول:
در مورد تابع rand سرچ کن
برای سوال 3
کد:http://www.irandevelopers.net/showthread.php?tid=297
Printable View
برای سوال 2نقل قول:
در مورد تابع rand سرچ کن
برای سوال 3
کد:http://www.irandevelopers.net/showthread.php?tid=297
این روش فقط برای ماتریس 3*3 درسته. برای 4*4 باید نسبت به یه سطر یا ستون بسط بدین. یعنی یه سطر(یا ستون)در نظر بگیرین برای هر عنصرش این کارو انجام بدین:نقل قول:
سطر و ستون شامل این عنصرو حدف کنین. دترمینان ماتریس 3*3 باقیمانده رو محاسبه کنین.حاصل رو در همون عنصر ضرب کنین.اگر i+j (شماره سطر و ستون عنصر) فرد بود در 1- ضرب کنین.
حالا برای همه عناصر همون سطر (یا ستون) یه عددی به دست اوردین. این اعدادو با در نظر گرفتن علامتشون با هم جمع کنین. دترمینان به دست میاد.
null یعنی بگین تو همش هیچیه. خالیه.البته فک کنم به صورت پیش فرض همه عناصر null باشن اما اگه بگین مطمئنتر میشین.
در کل اون مشکلی نداره باید اجرا شه کامپایلرو عوض کنید از همون 5.02 که دوستمون گفتند استفاده کنید چون منم تو همون کامپایل کردمنقل قول:
سعی کنید خودتون روش فکر کنید باز مشکلی بود بگیدنقل قول:
از صحت فایل هاش مطمئن نیستم چون سرچ کردمنقل قول:
کد:http://www.mediafire.com/?aymiyndyjif
سوال آخر هم سوال خوبیه تازه استاد زحمت کشیده فوق العاده اذیتتون کرده گفته از توابع آماده استفاده نکنید!!
نقل قول:
سوال خیلی کار میبره. شما شروع کنین به نوشتن . هرجایی به مشکل برخوردین بیاین بپرسین. نه اینکه کل کدو یکی بزنه اینجا براتون بذاره ، اینجوری هیچی یاد نمیگیرین!
مسعود جان ممنون
میشه در مورد خوندن یه خط از فایل از یه کاراکتر خاص تا یه کاراکتر خاص دیگه توضیح بدین؟
منمنون میشم یادم رفته:43:
سلام این سورس کد مربوط به سربار گذاری عملگر هاست دو تا ازش نوشتم ولی اور هاش باهم فرق می کنه لطفا کمک کنید
کد:
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
class string{
friend ostream & operator<<(ostream & , const string &);
friend istream & operator>>(istream & , string &);
public:
string();
void getstring();
string& operator = (cost string &);
string & operator +=(const string &);
bool operator ! () const;
bool operator == (const string &) const ;
bool operator < (const string &) const ;
bool operator = (const string &) const ;
bool operator > (const string &) const ;
bool operator <= (const string &) const ;
bool operator >= (const string &) const ;
bool getlength() const ;
private:
int length;
char st[80];
void setstring (char *);};
string::string (){
st[0]='\0';}
void string ::getstring (){
cout << "pleease enter string :"<<endl;
gets(st);
this-> getlength();}
string& string::operator=(const string & right){
setstring(rigth.st);
return *this;}
string & string::operator += (const string & right){
strcat (this ->st , right.st);
return *this ;}
bool string:: operator !() const{
return (length==0);}
bool string ::operator ==(const string & right) const{
return(strcmp (st , right.st));}
bool string ::operator !=(const string & right) const{
return!(strcmp(st,right.st))==0);}
bool string ::operator <=(const string & right) const{
return(strcmp(st,right.st)<=0);}
bool string ::operator >(const string & right) const{
return (strcmp(st, right.st)>0);}
bool string ::operator >=(const string & right) const{
return (strcmp(st, right.st)>=0);}
void string ::setstring (const char *st2){
strcpy(st, st2);}
void string::getlength() const{
length= strlen(st);}
ostream & operator << (ostream & output , const string & s){
output<<s.st;
return output;}
istream&operator>>(istream & input , string &s){
input>>s.st;
s.getlength();
return input;}
void main(){
string s1, s2, s3, s4;
cout<<"please enter a string :"<<endl;
cin>>s1;
cout<<"please enter a string :"<<endl;
s2.getstring();
s3=s1; s4=s3; s4=s2;
cout<<"s1==s2?";
cout<<((s1==s2)?"true" : "false")<<endl;
cout<<"(s1>s2)?";
cout<<((s1>s2)?"true" : "false")<<endl;
//else
cout<<"s4 is nul? ";
cout<<((s4!)?"true" : "false")<<endl;
cout<<s1<<endl;
cout<<s2<<endl;
cout<<s3<<endl;
cout<<s4<<endl;}
کد:#include <conio.h>
#include <string.h>
#include <stdio.h>
#include <iostream.h>
class string{
friend ostream& operator<<(ostream&,const string &);
friend istream& operator>>(istream&, string &);
public:
string();
void getstring();
string& operator=(const string &);
string& operator+=(const string &);
bool operator!()const;
bool operator==(const string &)const;
bool operator<(const string &)const;
bool operator!=(const string &)const;
bool operator>(const string &)const;
bool operator<=(const string &)const;
bool operator>=(const string &)const;
void getlenght()const;
private:
int lenght;
char st[80];
void setstring(char *);};
string::string()
{
st[0]='\0';}
void string::getstring()
{
cout<<"please enter string:";
gets(st);
this->getlenght();
}
string& string::operator=(const string & right);
{setstring(right.st);
return *this;}
string& string::operator+=(const string & right)
{strcat(this->st,right.st);
return *this;}
bool string::operator!()const
{return(lenght==0);}
bool string::operator ==(const string & right)const
{return(strcmp(st,right.st)==0);}
bool string::operator <(const string & right)const
{return (strcmp(st,right.st)<0);}
bool string::operator !=(const string & right)const
{return !(strcmp(st,right.st)==0);}
bool string::operator <=(const string & right)const
{return (strcmp(st,right.st)<=0);}
bool string::operator >(const string & right)const
{return(strcmp(st,right.st)>0);}
bool string::operator >=(const string & right)const
{return(strcmp(st,right.st)<=0);}
void string::setstring(const char *st2)
{strcpy(st,st2);}
void string::getlenght() const
{lenght=strlen(st);}
ostream& operator<<(ostream&output,const string & s)
{output<<s.st;
return output;}
istream& operator>>(istream&input,string& s)
{input>>s.st;
s.getlenght();
return input;}
void main(){
string s1,s2,s3,s4;
cout<<"please enter a string:"<<endl;
cin>>s1;
cout<<"please enter a string:"<<endl;
s2.getstring();
s3=s1;
s4=s3;
s4+=s2;
cout<<"s1==s2?";
cout<<((s1==s2)?"true":"false")<<endl;
cout<<"(s1>s2)?";
cout<<((s4>s2)?"true":"false")<<endl;
cout<<"s4 is NULL?";
cout<<((s4)!:?"true":"false")<<endl;
cout<<s1<<endl;
cout<<s2<<endl;
cout<<s3<<endl;
cout<<s4<<endl;}
این دومی 2 تا اور میده
برای اولی :
---------- Post added at 03:16 PM ---------- Previous post was at 03:14 PM ----------کد:
int a[5],b[5],k,i,j;
while (i<5 & j<5)
if (a[j]<b[j])
c[k++}=a[j++];
else
c[k++]=b[j++];
while (i<5)
c[k++]=a[j++];
while (j<5)
c[k++]=b[j++];
return 0;}
ببخشید مسعود جان این جواب نداد میشه یک بار دیگه از اول ( باورودی و خروجی ) بنویسی
ممنون.راستی فرض کن i<n,j<nهست.
کسی نیست جواب منو بده!
فکر کنم c++ برای این کار تابع داره
خیلی وقته ازش استفاده نمی کنم یادم رفته