سلام آبجی
خوب میدونید به ما یه پرژه شطرنج دادن که باید با جاوا به صورت انسان با انسان نوشته شه. کار زیادی داره ولی من باید 25 خرداد تحویل بدم . میتونیدکمکی به من کنید . ایمیل من هم اینه :
bad.paeizy@gmail.com
منتظر جواب شما هستم
نمایش نسخه قابل چاپ
سلام آبجی
خوب میدونید به ما یه پرژه شطرنج دادن که باید با جاوا به صورت انسان با انسان نوشته شه. کار زیادی داره ولی من باید 25 خرداد تحویل بدم . میتونیدکمکی به من کنید . ایمیل من هم اینه :
bad.paeizy@gmail.com
منتظر جواب شما هستم
کتابخانه با امکان ورود - ویرایش- حذف -به امانت گرفتن و پس دادن کتاب
کد PHP:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
//===========================
//===========================
class book
{
friend class library;
private:
char book_name[11];
char explain[51];
char aouther[11];
char part;
char user[11];
int reserved;
book *next;
public:
book();
void edit();
void reserv();
void getback();
}
//---------------------------
book::book()
{
clrscr();
cout<<"============ add a new book =================="
<<"\n\nto insert new book ,enter flow informations:"
<<"\n\nbook name?";
gets(book_name);
book_name[10]=NULL;
cout<<"\naouther name?";
gets(aouther);
aouther[10]=NULL;
cout<<"\nany explain?";
gets(explain);
explain[50]=NULL;
part=book_name[0];
reserved=0;
next=NULL;
cout<<"\n\ninformathions set!";
getch();
}
//---------------------------
void book::edit()
{
cout<<"error ";
}
//---------------------------
void book::reserv()
{
clrscr();
cout<<"\n=========== reserving book ===================";
if(reserved==0)
{
cout<<"\n\nuser name?";
gets(user);
user[11]=NULL;
reserved=1;
}
if(reserved==0)
{
cout<<"\n\nsorry! book has been reserved befor"
<<"by user:";
puts(user);
}
getch();
}
//---------------------------
void book::getback()
{
reserved=0;
cout<<"\n\nbook got bak.";
getch();
}
//===========================
//===========================
class library
{
public:
library();
void run_menu();
private:
book *parts[24];
void insert(book*);
void find();
void search();
}
//---------------------------
library::library()
{
for(int i=0;i<=23;i++)
parts[i]=NULL;
}
//---------------------------
void library::run_menu()
{
char ch='n';
while(ch!='4')
{
clrscr();
cout<<"================= LIBRARY =================="
<<"\n\n1:add a new book."
<<"\n2:find a book."
<<"\n3:search a book."
<<"\n4:exit."
<<"press numbers:";
ch=getch();
if(ch=='1')
{
book *n=new book;
insert(n);
}
if(ch=='2')
{
find();
}
if(ch=='3')
{
search();
}
}//while
}
//---------------------------
void library::insert(book *s)
{
int d=s->part-97;
if(parts[d]==NULL)
{
parts[d]=s;
}
else
{
book *p=parts[d],*q;
while(p!=NULL && strcmp(p->book_name,s->book_name)<0)
{
q=p;
p=p->next;
}
q->next=s;
s->next=p;
}
}
//---------------------------
void library::find()
{
clrscr();
cout<<"=========== edit / delete books ============"
<<"\nenter exact book name:";
char name[11];
gets(name);
name[11]=NULL;
int d=name[0]-97;
book *p=parts[d],*q;
while(p!=NULL && strcmp(p->book_name,name)!=0)
{
q=p;
p=p->next;
}
if(p==NULL)
{
cout<<"not found!";
}
if(p!=NULL)
{
cout<<"\n\ndelete it?('d') or edit?('e')"
<<" or reserv?('r') or getback?('g') :";
char ch=getch();
if(ch=='d')
{
q->next=p->next;
delete p;
}
if(ch=='e')
{
p->edit();
}
if(ch=='r')
{
p->reserv();
}
if(ch=='g')
{
p->getback();
}
}
getch();
}
//---------------------------
void library::search()
{
char ch='6';
while(ch!='4')
{
clrscr();
cout<<"================== SEARCH ===================";
cout<<"\n\n1:search for name."
<<"\n2:search for aouther."
<<"\n3:search for explanations."
<<"\n4:back to main menu.(press numbers)";
ch=getch();
if(ch=='1')
{
cout<<"\n\nenter exact name:";
char name[10];
gets(name);
name[11]=NULL;
int d=name[0]-97;
book *p=parts[d];
while(p!=NULL && strcmp(p->book_name,name)!=0)
{
p=p->next;
}
if(p==NULL)
{
cout<<"\nnot founded!";
}
else
{
cout<<"\n\n";
cout<<"name:";puts(p->book_name);
cout<<"aouther:";puts(p->aouther);
cout<<"explain:";puts(p->explain);
if(p->reserved==1)
{
cout<<"RESERVED by:";
puts(p->user);
}
else
{
cout<<"NOT RESERVES";
}
}//else
getch();
}//1
if(ch=='2')
{
cout<<"\n\nenter exact aouther name:";
char name[11];
gets(name);
name[11]=NULL;
int f=0;
for(int i=0;i<=23;i++)
{
book *p=parts[i];
while(p!=NULL)
{
if(strcmp(p->aouther,name)==0)
{
f++;
cout<<"\n"<<f<<":";
cout<<"name:";puts(p->book_name);
cout<<"aouthor:";puts(p->aouther);
cout<<"explain:";puts(p->explain);
if(p->reserved==1)
{
cout<<"RESERVED BY";
puts(p->user);
}
else
{
cout<<"NOT RESERVED";
}
}
p=p->next;
}//while
}
getch();
}//2
if(ch=='3')
{
cout<<"\n\nenter key(15char):";
char name[16];
gets(name);
name[15]=NULL;
int f=0;
for(int i=0;i<=23;i++)
{
book *p=parts[i];
while(p!=NULL)
{
char *tokenptr;
tokenptr=strtok(p->explain," ");
while(tokenptr!=NULL)
{
if(strcmp(tokenptr,name)==0)
{
f++;
cout<<"\n"<<f<<":";
cout<<"name:";puts(p->book_name);
cout<<"aouthor:";puts(p->aouther);
cout<<"explain:";puts(p->explain);
if(p->reserved==1)
{
cout<<"RESERVED BY";
puts(p->user);
}
else
{
cout<<"NOT RESERVED";
}
}
tokenptr=strtok(NULL," ");
}
p=p->next;
}//while
}//for i
getch();
}//3
}
}
//===========================
//===========================
int main()
{
clrscr();
library l1;
l1.run_menu();
return(0);
}
مشخصات دانشجویان با امکان ورود اطلاعات حذف اطلاعات و جستجو
کد PHP:
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
struct student{
char name[20];
char family[25];
int id;
student *next;
};
student *first,*last;
//////////////////////////
void input(){
student *temp=new student;
cout<<"plese enter the id : "<<endl;
cin>>temp->id;
cout<<"plese enter the name : "<<endl;
cin>>temp->name;
cout<<"plese enter the family : "<<endl;
cin>>temp->family;
if (first==NULL){
first=last=temp;
}
else {
temp->next=last;
last=temp;
}
}
/////////////////////////////////
void output(){
student *temp=new student;
temp=first;
while(temp!=NULL){
cout<<temp->id<<endl;
cout<<temp->name<<endl;
cout<<temp->family<<endl;
cout<<"*************************************";
temp=temp->next;
}
cout<<"end of record"<<endl;
}
/////////////////////////////////////
void search(int id){
student *temp=new student;
int find;
temp=first;
while(temp!=NULL){
if (id==temp->id){
cout<<temp->id<<endl;
cout<<temp->name<<endl;
cout<<temp->family<<endl;
find=1;
break;
}
else{
find=0;
temp=temp->next;
}
}
if (find==0){ cout<<"not find record"<<endl;}
}
////////////////////////////////////
void main(){
int stat;
for (;;){
system("cls");
cout<<"***************************************"<<endl;
cout<<"num 1 for input data " <<endl;
cout<<"num 2 for list data " <<endl;
cout<<"num 3 for search data " <<endl;
cout<<"num 4 for exit" <<endl;
cout<<"***************************************"<<endl ;
cin>>stat;
system("cls");
switch(stat){
case 1:
input();
break;
case 2:
output();
break;
case 3:
int key;
cout<<"plese enter id for search : " ;
cin>>key;
search(key);
break;
case 4:
exit(0);
}
}
}
دفتر تلفن ساده با کلاس ها
کد PHP:
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
//=====================================
//=====================================
struct address {
char name[30] ;
char street[30] ;
char city[20] ;
char state[3] ;
char number[14] ;
struct address *next ;
struct address *prior ;
} list_entry ;
//=====================================
//=====================================
struct address *start ;
struct address *last ;
void enter() , display() , search() ;
void list() , del();
void display(struct address *info, int *row);
struct address *find(char *);
int menu_select();
struct address *store(struct address *, struct address *);
//=====================================
//=====================================
//****************
int menu_select()
{
char s[5];
system("cls");
gotoxy(25,4) ;
printf("1. enter a name ") ;
gotoxy(25,6) ;
printf("2. delete a name ") ;
gotoxy(25, 8) ;
printf("3. list all files ") ;
gotoxy(25, 10) ;
printf("4. search ") ;
gotoxy(25, 12) ;
printf("5. quit ") ;
do {
gotoxy(20, 18) ;
printf("enter your select--power By majid (1-5):");
gets(s);
} while (atoi(s) < 0 || atoi(s) > 5) ;
return atoi(s) ;
}
//*********************
void enter ()
{
struct address *info ;
int i ;
char ch ;
system("cls") ;
gotoxy(3, 2) ;
printf(" name street city state number");
gotoxy(3, 3) ;
printf(" ------------ -------- ");
printf("-------- ----- ------- ");
i = 4 ;
for (;;) {
info = (struct address *)malloc(sizeof(list_entry)) ;
if(!info) {
printf("\n out of memory. press a key ") ;
getch();
return ;
}
gotoxy(3, i) ;
gets(info -> name) ;
if (!info -> name[0]) {
gotoxy(15, i + 1) ;
printf("press a key to continue");
getch() ;
break ;
}//end of if
gotoxy(18, i);
gets(info -> street) ;
gotoxy(28, i) ;
gets(info -> city) ;
gotoxy(38, i) ;
gets(info -> state) ;
gotoxy(45, i) ;
gets(info -> number) ;
i++ ;
start = store(info, start) ;
} /* entry loop */
}
//**************
struct address *store(struct address *i, struct address *top)
{
struct address *old, *p ;
if(last == NULL) {
i -> next = NULL ;
i -> prior = NULL ;
start = i;
last = i ;
return i ;
}
p = top ;
old = NULL ;
while (p != NULL) {
if(strcmp(p -> name, i -> name) < 0) {
old = p ;
p = p -> next ;
}//end of if
else {
if (p -> prior) {
p -> prior -> next=i ;
i -> next=p ;
i -> prior=p -> prior;
p -> prior=i ;
return top ;
}//end of if
i -> next = p ;
i -> prior = NULL ;
p -> prior = i ;
return i ;
}//end of if
} // end of while
old -> next = i ;
i -> next = NULL ;
i -> prior = old ;
last = i ;
return start ;
}
//******************
void del()
{
struct address *info;
char name[80];
gotoxy(20, 20) ;
printf(" enter name for delete : ") ;
gets(name) ;
info = find(name) ;
if(info == NULL) {
gotoxy(10, 20) ;
printf(" name not found! press a key to continue.");
getch() ;
}
if (info)
if (start == info)
{
start = info -> next ;
if(start)
start -> prior = NULL ;
else
last = NULL ;
} //end of if
else {
info -> prior -> next = info -> next;
if(info != last)
info -> next -> prior = info -> prior;
else
last = info -> prior ;
} //end of else
free(info) ;
gotoxy(10,20) ;
printf("name deleted, press a key to continue.");
getch() ;
}
//*******************************
struct address *find(char *name)
{
struct address *info ;
info = start ;
while(info != NULL) {
if (strcmp(name, info -> name) == 0)
return info;
info = info -> next ;
}
return NULL ;
}
//*****************
void list ()
{
struct address *info ;
int i ;
info = start ;
system("cls") ;
gotoxy(3, 2) ;
printf(" name street city state number");
gotoxy(3, 3) ;
printf(" ------------ -------- -");
printf("------- ----- ------- ");
i = 4 ;
while(info != NULL) {
display(info, &i) ;
info = info -> next ;
}
gotoxy(15, i + 2) ;
printf("press a key to continue.");
getch() ;
}
//*******************
void display(struct address *info, int *row)
{
gotoxy(3, *row) ;
printf("%s", info -> name) ;
gotoxy(18, *row) ;
printf("%s", info -> street) ;
gotoxy(28, *row) ;
printf("%s", info -> city) ;
gotoxy(38, *row) ;
printf(info -> state) ;
gotoxy(47, *row) ;
printf(info -> number) ;
*row = *row + 1 ;
}
//**************************
void search()
{
char name[40] ;
int i ;
struct address *info;
gotoxy(20, 20) ;
printf(" enter name to find : ");
gets(name) ;
info = find(name) ;
if(info == NULL) {
gotoxy(10, 20) ;
printf(" name not found! press a key to continue.");
getch() ;
}//end of if
else {
system("cls") ;
gotoxy(3, 2) ;
printf(" name street city state number");
gotoxy(3, 3) ;
printf(" ------------ -------");
printf("- -------- ----- ------- ") ;
i = 4 ;
display(info ,&i) ;
gotoxy(15, i + 2) ;
printf("press a key to continue.");
getch() ;
}//end of else
}
//*********************
int main()
{
start = last = NULL ;
for(;;) {
switch(menu_select()) {
case 1: enter(); break ;
case 2 : del(); break ;
case 3: list() ; break ;
case 4: search(); break ;
case 5: exit(0) ;
}//end of switch
}//end of for
}//end of main
اوور لودینگ اپراتورها در کلاس در c++
کد PHP:
#include <iostream.h>
#include <string.h>
#include <conio.h>
#include <stdio.h>
class string
{
private:
char text[40];
public:
void show()
{
cout << text << "\n";
}
string operator + (string s)
{
string temp;
strcpy(temp.text, text);
strcat (temp.text, s.text);
return temp;
}
string operator + (char s[])
{
string temp;
strcpy(temp.text, text);
strcat (temp.text, s);
return temp;
}
string operator++()
{
char temp[40];
strcpy(temp , text);
strcat(text,temp);
}
friend string operator +(char s[] , string s2)
{
string temp;
strcpy(temp.text , s);
strcat(temp.text , s2.text);
return temp;
}
string operator =(char s[])
{
strcpy(text , s);
}
string operator =(string s)
{
strcpy(text , s.text);
}
};
void main()
{
string s1 , s2 , s3;
clrscr();
s1 = "Ali";
char temp[]={"Ali"};
s2 = temp;
s3 = "hossein";
s1++;
s1.show();
s1 = temp + s3;
s1.show();
s2 = s1;
s2.show();
s2 = s2 + "azarpevand";
s2.show();
getch();
}
اطلاعات عمومی دانشجو
خصوصیات برنامه:
1)وارد کردن نمره به تعداد دلخواه
2)بازه نمرات بین 0 تا 100
3)مشخص کردن وضعیت نمرات
4)گرفتن میانگین
5)مشخص کردن تعداد افراد قبول و مردود شده
کد PHP:
#include <iostream.h>
#include <conio.h>
int main()
{
float x, counter=1, counterp=0, counterf=0,ave=0,y,m;
cout<<"How many mark? ";
cin>>y;
cout<<"Pass and Fail: ";
cin>>m;
cout<<"#########################################";
cout<<"\n";
while (counter<=y){
cout<<"Mark "<<counter<<": ";
cin>>x ;
counter=counter+1;
ave+=x;
if (x>100){
cout<<"ERROR:FALSE MARK"<<"\n";
cout<<"\n";
cout<<"egain enter the ";
counter=counter-1;
}
else if (x>=m){
cout<<"Pass"<<"\n"<<"*********************"<<"\n"<<"\n";
counterp+=1;
}
else{
cout<<"Fail"<<"\n"<<"*********************"<<"\n"<<"\n";
counterf+=1;
}
}
if (counter=y){
cout<<"Pass number: "<<counterp<<"\n";
cout<<"Fail number: "<<counterf<<"\n";
cout<<"Average: "<<ave/y<<endl;
}
getch();
return 0;
}
برنامه رسم خط DDA بزبان ++c
کد PHP:
#include
#include
#include
int main()
{
int driver = DETECT,mode;
initgraph(&driver,&mode,"c:\\borlandc\\bgi");
float x1,x2,y1,y2,i;
float ytemp,xtemp;
float m;
cout<<"Enter x1 , y1"<
cin>>x1>>y1;
cout<<"Enter x2 , y2"<
cin>>x2>>y2;
m = (y2-y1)/(x2-x1);
ytemp=y1;
xtemp=x1;
if (m<1){
for (i = 0; i <= x2-x1; i++)
{
putpixel(xtemp,ytemp,4);
ytemp+=m;
xtemp++;
}
}
else
{
for (i=y1; i
{
putpixel(xtemp,i,4);
xtemp=(xtemp*m+1)/m;
}
}
getch();
return 0;
}
برنامه رسم دایره برسنهام بزبان ++c
کد PHP:
#include
#include
#include
#include
void main()
{
//Detect Graphic Mode
int driver = DETECT,mode;
initgraph(&driver,&mode,"c:\\tc\\bgi");
//Program Start
int xcenter,ycenter,r,x,y,p,i;
cout<<"Enter R"< cin>>r;
xcenter=r;
ycenter=r;
x=0;
y=r;
p=1-r;
putpixel(xcenter+x,ycenter+y,2);
while (x {
x++;
if (p<0)
p+=2*x+1;
else
{
p+=2*(x-y)+1;
y--;
}
putpixel(xcenter+x,ycenter+y,2);
putpixel(xcenter-x,ycenter+y,2);
putpixel(xcenter+x,ycenter-y,2);
putpixel(xcenter-x,ycenter-y,2);
putpixel(xcenter+y,ycenter+x,2);
putpixel(xcenter-y,ycenter+x,2);
putpixel(xcenter+y,ycenter-x,2);
putpixel(xcenter-y,ycenter-x,2);
}
getch();
}
این برنامه ساده دو عدد ورودی را گرفته و عمل x AND Y را انجام داده و نتیجه رو چاپ میکند!
کد PHP:
#include <iostream.h>
int add(int number, int number2)
{
int answer;
_asm{
MOV EAX, number;
MOV EBX, number2;
ADD EAX, EBX;
MOV answer, EAX;
}
return answer;
}
int main(int argc, char* argv[])
{
int number;
int number2;
int answer;
cout << "Enter a number: ";
cin >> number;
cout << "\n\nEnter another number: ";
cin >> number2;
answer = add(number, number2);
cout << "\n\n" << number << " and " << number2 << " is " << answer << endl;
return 0;
}