master.
Registered User
ممنونم از همگی
آرش جان چشم حق با شماست ...
آرش جان چشم حق با شماست ...
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <iomanip.h>
void main()
{
int j,i;
for (i=1;i<=10;i++){
for (j=1;j<=10;j++){
cout<<setw(2)<<i<<"*"<<j<<"="<<i*j;
if(j%10==0) cout<<endl<<endl;
}
}
}
ممنون که کمک کردیجان ببخشید اون تابع که من گفتم ربطی نداشت یه جا دیگه استفاده میشه شما باید از تابع <graphics.h>استفاده کنی
خواهش میکنم!!ممنون که کمک کردی![]()
int fibo(int n)
{
if(n < 2 )
return 1;
return fibo(n-1)+fibo(n-2);
}
int fibo(int n)
{
int a1,a2;
a1=a2=1;
for(int tmp,i = 2 ; i< n ; ++i)
{
tmp,=a1+b2;
a2=a1;
a1=tmp;
}
return a1;
}
سلام.می شه کد این برنامه رو برام بنویسید آخه من سر جلسه تابع نبودم
با استفاده از تابع فاکتوریل عدد را به دو روش (بدون ارسال و با ارسال. دو برنامه جدا از هم) مقدار بدست آورید.
منتظرم.
مرسی![]()
#include <iostream>
#include <conio.h>
#include <vector>
using namespace std;
void get();
int main()
{
get();
getch();
return 0;
}
void get()
{
char ch;
ch=getch();
if(ch!='q'||ch!='Q')
get();
else
{
cout<<ch;
return;
}
}
/*
Name:Complex class compiler:dev-c++ 4.9.9.2
Copyright: www.codecorona.com
Author: Mohammad yazdani
Description: This class make complex number like a simple data type in c++.
*/
//**********************header files********************************************
#include <iostream>
#include <conio.h>
using namespace std;
//***************designing class************************************************
class complex{
public:
complex(int=0,int=0);
complex operator+(complex);
complex operator+(int);
complex operator-(complex);
complex operator-(int);
complex operator*(complex);
complex operator*(int);
complex operator/(complex);
complex operator/(int);
friend ostream&operator<<(ostream&,complex);
friend istream&operator>>(istream&,complex&);
private:
float real;
float unreal;
};
//*********implementing member functions****************************************
complex::complex(int a,int b)
{
real=a;
unreal=b;
}
//*********************************
complex complex::operator+(complex b)
{
complex c;
c.real=real+b.real;
c.unreal=unreal+b.unreal;
return c;
}
//**********************************
complex complex::operator+(int a)
{
this->real+=a;
this->unreal+=a;
return *this;
}
//***********************************
complex complex::operator-(complex b)
{
complex c;
c.real=real-b.real;
c.unreal=unreal-b.unreal;
return c;
}
//************************************
complex complex::operator-(int a)
{
this->real-=a;
this->unreal-=a;
return *this;
}
//************************************
complex complex::operator*(complex b)
{
complex c(0,0);
c.real=this->real*b.real;
c.unreal=this->unreal*b.unreal*(-1);
return c;
}
//*************************************
complex complex::operator*(int a)
{
this->real*=a;
this->unreal*=a;
return *this;
}
//**************************************
complex complex::operator/(complex b)
{
complex c;
c.real=real/b.real;
c.unreal=unreal/b.unreal;
return c;
}
//***************************************
complex complex::operator/(int a)
{
this->real/=a;
this->unreal/=a;
return *this;
}
//***************************************
ostream&operator<<(ostream&out,complex b)
{
out<<b.real<<(b.unreal>0?'+':' ')<<b.unreal<<'i';
return out;
}
//****************************************
istream&operator>>(istream&in,complex& b)
{
cout<<"please enter the the real section:";
in>>b.real;
cout<<"\nplease enter the unreal section:";
in>>b.unreal;
return in;
}
//****************************************main function*************************
int main()
{
complex a(4,3),b(2,6);
cout<<endl<<a*b;
cout<<endl<<a;
cout<<endl<<a/b;
cout<<endl<<a-2;
getch();
return 0;
}
//******************************************************************************
#include <iostream>
#include <conio.h>
using namespace std;
//***designing class*************//
class complex{
public:
complex(int=0,int=0);
complex operator+(complex);
complex operator+(int);
complex operator+(int,complex);
complex operator-(complex);
complex operator-(int);
complex operator-(int,complex);
complex operator*(complex);
complex operator*(int,complex);
complex operator*(int);
complex operator/(complex);
complex operator/(int,complex);
complex operator/(int);
friend ostream&operator<<(ostream&,complex);
friend istream&operator>>(istream&,complex&);
private:
int real;
int unreal;
};
//*********implementing funcion members************
complex::complex(int a,int b)
{
real=a;
unreal=b;
}
//****************
complex complex::operator+(complex b)
{
complex c;
c.real=this->real+b.real;
c.unreal=this->unreal+b.unreal;
return c;
}
//*****************
complex complex::operator+(int b)
{
complex c;
c.real=this->real+b;
c.unreal=this->unreal+b;
return c;
}
//*****************
complex complex::operator+(int b,complex a)
{
return (a+b);
}
//*****************
complex complex::operator-(complex b)
{
complex c;
c.real=real-b.real;
c.unreal=unreal-b.unreal;
return c;
}
//*****************
complex complex::operator-(int b)
{
complex c;
c.real=this->real-b;
c.unreal=this->unreal-b;
return c;
}
//*****************
complex complex::operator-(int b,complex a)
{
complex c;
c.real=b-a.real;
c.unreal=b-a.unreal;
return c;
}
//******************
complex complex::operator*(complex b)
{
complex c;
c.real=real*b.real;
c.unreal=unreal*b.unreal*(-1);
return c;
}
//*****************
complex complex::operator*(int b)
{
complex c;
c.real=this->real*b;
c.unreal=this->unreal*b;
return c;
}
//******************
complex complex::operator*(int b,complex a)
{
return (a*b);
}
//*******************
complex complex::operator/(complex b)
{
complex c;
c.real=real/b.real;
c.unreal=unreal/b.unreal;
return c;
}
//******************
complex complex::operator/(int b)
{
complex c;
c.real=this->real/b;
c.unreal=this->unreal/b;
return c;
}
//*******************
complex complex::operator/(int b,complex a)
{
complex c;
c.real=b/a.real;
c.unreal=b/a.unreal;
return c;
}
//********************
ostream&operator<<(ostream&out,complex b)
{
out<<b.real<<(b.unreal>0?'+':' ')<<b.unreal<<'i';
return out;
}
//*******************
istream&operator>>(istream&in,complex& b)
{
cout<<"please enter the the real section:";
in>>b.real;
cout<<"\nplease enter the unreal section:";
in>>b.unreal;
return in;
}
//****************************************main function*************************
int main()
{
complex a(4,3),b(2,6);
cout<<a+b<<endl<<a+2<<endl<<2+a;
cout<<endl<<a-b<<endl<<2-b<<endl<<b-2;
cout<<endl<<a*b<<endl<<a*2<<2*a;
cout<<endl<<a/b<<endl<<a/2<<endl<<2/a;
getch();
return 0;
}
//******************************************************************************
/*
Name:The MOVMENT OF A HOURSE IN A CHESS
Copyright:WWW.CODECORONA.COM
Author:MOHAMMAD YAZDANI
*/
//*******************************HEADER FILES***********************************
#include <iostream>
#include <conio.h>
#include <string>
#include <iomanip>
#include <cstdlib>
#define row 8
#define col 8
using namespace std;
//***************************FUNCTION PROTOTYPE*********************************
void print(int[row][col]);
void input(int&,int&);
void move (int[row][col],int,int);
void motion(int&,int&,int,bool&);
//*****************************MAIN FUNCTION************************************
int main()
{
int table[row][col]={0};
int x,y;
input(x,y);
move(table,x,y);
cout<<"the final table to made with your movment is:\n\n";
print(table);
getch();
return 0;
}
//******************************************************************************
void input(int&x,int&y)
{
int z=-1;
do{
system("cls");
z++;
if(z)
cout<<"\a";
cout<<"please enter the row for start between(0 -7):";
cin>>x;
cout<<"\nplease enter the coloum for start (0-7):";
cin>>y;
}while((x<0||x>7)||(y<0||y>7));
}
//******************************************************************************
void move(int t[row][col],int x,int y)
{
t[x][y]=1;
int k=0;
cout<<"the start point for this board is row "<<x<<" && coloum "<<y<<endl<<endl;
print(t);
while(k++<8)
{
int number;
static int pos=1;
int mov=0;
bool error=false;
do{
system("cls");
print(t);
cout<<"\nthe poosible movment in the board.";
cout<<"\n\nnumber 1: 2 cell top && 1 cell left"
"\n\nnumber 2: 2 cell top && 1 cell right"
"\n\nnumber 3: 2 cell left && 1 cell down"
"\n\nnumber 4: 2 cell left && 1 cell top."
"\n\nnumber5: 2 cell right && 1 cell down"
"\n\nnumber 6: 2 cell right && 1 cell top"
"\n\nnumber 7: 2 cell down && 1 cell right"
"\n\number 8: 2 cell down && 1 cell left."
"\n\nnumber 9:Exit from program.";
cout<<" \n \n\nplease choos one of this movment:";
cin>>number;
}while(number<1||number>9);
switch (number)
{
case 1:
motion(x,y,1,error);
if(error)
{
cerr<<"\athis movment can not be done in chess.\n";
k--;
getch();
print (t);
}//end of if
else
{
t[x][y]=++pos;
print(t);
}//end of else
break;
case 2:
motion(x,y,2,error);
if(error)
{
cerr<<"\athis movment can not be done in chess.\n";
k--;
getch();
print(t);
}//end of if
else
{
t[x][y]=++pos;
print(t);
}//end of else
break;
case 3:
motion(x,y,3,error);
if(error)
{
cerr<<"\athis movment can not be done in chess.\n";
k--;
getch();
print(t);
}//end of if
else
{
t[x][y]=++pos;
print(t);
}//end of else
break;
case 4:
motion(x,y,4,error);
if(error)
{
cerr<<"\athis movment can not be done in chess.\n";
k--;
getch();
print(t);
}
else
{
t[x][y]=++pos;
print(t);
}
break;
case 5:
motion(x,y,5,error);
if(error)
{
cerr<<"\athis movment can not be done in chess.\n";
k--;
getch();
print(t);
}
else
{
t[x][y]=++pos;
print(t);
}
break;
case 6:
motion(x,y,6,error);
if(error)
{
cerr<<"\athis movment can not be done in chess.\n";
k--;
getch();
print(t);
}
else
{
t[x][y]=++pos;
print(t);
}
break;
case 7:
motion(x,y,7,error);
if(error)
{
cerr<<"\athis movment can not be done in chess.\n";
k--;
getch();
print(t);
}
else
{
t[x][y]=++pos;
print(t);
}
break;
case 8:
motion(x,y,8,error);
if(error)
{
cerr<<"\athis movment can not be done in chess.\n";
k--;
getch();
print(t);
}
else
{
t[x][y]=++pos;
print(t);
}
break;
case 9:
exit(0);
}//end of switch
}//end of while(1)
}//end of move function
//******************************************************************************
void print(int t[row][col])
{
int i,j;
cout<<" ";
for(i=0;i<row;i++,cout<<endl<<endl<<" ")
for(j=0;j<col;j++)
cout<<t[i][j]<<" ";
getch();
}
//******************************************************************************
void motion(int &x,int&y,int t,bool& index)
{
switch (t){
case 1:
x-=2;
y-=1;
if((x<0 ||y<0)||(x>7||y>7))
{
index=true;
x+=2;
y+=1;
}//end of if
else
index=false;
break;
case 2:
x-=2;
y+=1;
if((x<0 ||y<0)||(x>7||y>7))
{
index=true;
x+=2;
y-=1;
}//end of if
else
index=false;
break;
case 3:
y-=2;
x+=1;
if((x<0 ||y<0)||(x>7||y>7))
{
index=true;
x-=1;
y+=2;
}//end of if
else
index=false;
break;
case 4:
y-=2;
x-=1;
if((x<0 ||y<0)||(x>7||y>7))
{
index=true;
x+=1;
y+=2;
}//enf of if
else
index=false;
break;
case 5:
y+=2;
x+=1;
if((x<0 ||y<0)||(x>7||y>7))
{
index=true;
x-=1;
y-=2;
}//enf of if
else
index=false;
break;
case 6:
y+=2;
x-=1;
if((x<0 ||y<0)||(x>7||y>7))
{
index=true;
x+=1;
y-=2;
}//end of if
else
index=false;
break;
case 7:
x+=2;
y+=1;
if((x<0 ||y<0)||(x>7||y>7))
{
index=true;
x-=2;
y-=1;
}//enf of if
else
index=false;
break;
case 8:
x+=2;
y-=1;
if((x<0 ||y<0)||(x>7||y>7))
{
index=true;
x-=2;
y+=1;
}//end of if
else
index=false;
break;
}//end of switch
}
//******************************************************************************