PDA

توجه ! این یک نسخه آرشیو شده می باشد و در این حالت شما عکسی را مشاهده نمی کنید برای مشاهده کامل متن و عکسها بر روی لینک مقابل کلیک کنید : پروژه های نوشته شده به زبان سی پلاس پلاس



sunyboy
09-21-2008, 06:15 PM
سلام دوستان در اینجا قراره برنامه ها و پروژ های نوشته شده به زبان سی پلاس پلاس رو قرار بدیم

شما هم اگر برنامه ای و یا پروژه ای دارین در اینجا قرار بدین تا بقیه استفاده کنند


در ضمن اگر پروژه یا برنامه ای استادتان ازتون خواسته که نمیتونید انجام بدید در اینجا مطرح کنید اگر وقت کردم براتون می نویسم


با احترام




برنامه مدیریت پیشرفته کتابخانه بزبان++ c


این برنامه را بزبان ++C که با استفاده از کلاس ها و وراثت و خاصیت شیی گرایی نوشته ام


لینک دریافت:
http://w14.easy-share.com/1701656974.html

پسورد فایل: www.forum.daneshjuha.org (http://www.forum.daneshjuha.org)

sunyboy
10-16-2008, 12:38 AM
دوستان عزیز یادآوری می کنم که پروژه هایی که در اینجا قرار دارن و یا قرار داده میشوند در سایتهای دیگر با مبالغی حدود 15تا 30 هزار تومان به فروش می رسند!!

sunyboy
10-16-2008, 12:42 AM
پروژه حرکت اسب در شطرنج


پسورد فایل: www.forum.daneshjuha.org (http://www.forum.daneshjuha.org)

sunyboy
10-16-2008, 12:50 AM
پروژه هشت وزیر

پسورد فایل: www.forum.daneshjuha.org (http://www.forum.daneshjuha.org)

sunyboy
10-16-2008, 12:55 AM
پروژه تشخیص ماتریس بالا یا پایین مثلثی


پسورد فایل: www.forum.daneshjuha.org (http://www.forum.daneshjuha.org)

sunyboy
10-16-2008, 12:59 AM
پروژه ماتریس اسپارس

پسورد فایل: www.forum.daneshjuha.org (http://www.forum.daneshjuha.org)

sunyboy
10-16-2008, 01:03 AM
پروژه کد مورس


پسورد فایل: www.forum.daneshjuha.org (http://www.forum.daneshjuha.org)

sunyboy
10-16-2008, 01:09 AM
پروژه پیانوی مجازی


پسورد فایل: www.forum.daneshjuha.org (http://www.forum.daneshjuha.org/)

sunyboy
10-16-2008, 01:13 AM
برنامه ای که تمام عملگر ها را سر بار گذاری کند


پسورد فایل: www.forum.daneshjuha.org (http://www.forum.daneshjuha.org)

karma
10-23-2008, 10:51 PM
برنامه مرتب سازی سریع
http://iranupload.net/file.php?file=f4f8d36ea96f5e43d0cae548d1c50db0

karma
10-23-2008, 11:02 PM
#include <iostream.h>
#include <conio.h>
void null(int *n);
int main()
{
int n,f;
gotoxy(30,3);
cout<<"*** Welcome ***";
gotoxy(55,23);
cout<<"*** SPRING OF 1387 ***";
gotoxy(1,10);
cout<<"please enter a number :";
cin>>n;
null(&n);
getch();
return 0;
}
//****************************
void null(int*n)
{
gotoxy(1,13);
for(int i=2;i<*n;i++)
{
int flag=1;
for(int j=2;j<i;j++)
if(i%j==0)flag=0;
if(flag!=0)cout<<i<<" ";
}
}
این برنامه یک عدد را از شما می گیره و اعداد اول از یک تا اون عدد را چاپ می کنه

karma
10-23-2008, 11:06 PM
#include <iostream>
#include <conio>
int pop(int,int,int*);
int push(int,int *);
void print(int *);
int array[10],item;
int main()
{
int top=-1;
char ch=100;
while(ch!='3'&&ch!=27)
{
clrscr();
cout<<"\n\nWhat do you want to do:";
cout<<"\n\n1-Pop";
cout<<"\n2-Push";
cout<<"\n3-Exit";
cout<<"\n\nWhat is your choise(1,2,3):";
ch=getch();
switch(ch)
{
case'1':
clrscr();
cout<<"\n\nPlease enter a number:";
cin>>item;
top=pop(item,top,array);
print(array);
getch();
break;
case'2':
clrscr();
top=push(top,array);
print(array);
getch();
break;
case'3':return 0;
}
}
getch();
return 0;
}
//************************************************** ****************************
int pop(int x,int up,int *stack)
{
up++;
if(up>9)
cout<<"Sorry Stack Is Full";
else
stack[up]=x;
return up;
}
//*************************************
int push(int up,int *stack)
{
if(up<0)
cout<<"\nSorry Stack Is Empety\n\n";
else
{
stack[up]=0;
up--;
}
return up;
}
//*************************************
void print(int *stack)
{
for(int i=0;i<10;i++)
cout<<stack[i]<<" ";
}

karma
10-23-2008, 11:07 PM
#include <iostream>
#include <conio>
int add(int,int,int*);
int delet(int,int,int*);
void print(int *);
int saf[10],item;
int main()
{
int rear=-1,front=-1;
char ch=100;
while(ch!='3'&&ch!=27)
{
clrscr();
cout<<"\n\nWhat do you want to do:";
cout<<"\n\n1-Add";
cout<<"\n2-Delete";
cout<<"\n3-Exit";
cout<<"\n\nWhat is your choise(1,2,3):";
ch=getch();
switch(ch)
{
case'1':
clrscr();
cout<<"\n\nPlease enter a number:";
cin>>item;
rear=add(item,rear,saf);
print(saf);
getch();
break;
case'2':
clrscr();
front=delet(front,rear,saf);
print(saf);
getch();
break;
case'3':return 0;
}
}
getch();
return 0;
}
//***********************************************
int add(int item,int r,int*q)
{
if(r>9)
cout<<"The queue is full\n\n";
else
q[++r]=item;
return r;
}
//***********************************************
int delet(int f,int r,int*q)
{
if(f==r)
cout<<"The queue is empety\n\n";
else
q[++f]=0;
return f;
}
//***********************************************
void print(int *q)
{
for(int i=0;i<10;i++)
{
cout<<q[i];
if(i<9)cout<<",";
}
}

karma
10-23-2008, 11:09 PM
#include <iostream>
#include <conio>
void add(int,int*,int*,int*);
int delet(int*,int*,int*,int*);
void print(int*);
int queue[10],item;
int main()
{
int rear=0,front=0,remove;
char ch=100;
while(ch!='4'&&ch!=27)
{
clrscr();
cout<<"What do you want to do?\n\n";
cout<<"1-Add\n2-Delete\n3-Print\n4-Exit\n\n";
cout<<"What is your selection :";
ch=getch();
switch(ch)
{
case'1':
clrscr();
cout<<"Please eneter a number :";
cin>>item;
add(item,&rear,&front,queue);
break;
case'2':
clrscr();
remove=delet(&item,&rear,&front,queue);
if(remove!=0)
cout<<"Deleted number is :"<<remove;
queue[front]=0;
getch();
break;
case'3':
clrscr();
cout<<"The queue is :";
print(queue);
getch();
break;
case'4':
return 0;
}
}
getch();
return 0;
}
//***********************************************
void add(int item,int*r,int*f,int*q)
{
if(*r==9)
*r=0;
else
*r+=1;
if(*r==*f)
{
cout<<"Queue is full";
*r-=1;
getch();
}
else
q[*r]=item;
}
//***********************************************
int delet(int*item,int*r,int*f,int*q)
{
if(*f==*r)
{
cout<<"Queue is empety";
return 0;
}
else
{
if(*f==9)
*f=0;
else
*f+=1;
}
return q[*f];
}
//***********************************************
void print(int *q)
{
cout<<"\n";
for(int i=0;i<10;i++)
{
cout<<q[i];
if(i<9)cout<<",";
}
}

karma
10-23-2008, 11:11 PM
#include <iostream>
#include <conio>
void pop(char,int*,char*);
void print(char*);
char push(int*,char*);
char in[50],out[50],stack[50],ch;
int main()
{
int top=-1,i,j=0;
clrscr();
cout<<"\n\nPlease enter your prasse:";
cin>>in;
for(i=0;i<50;i++)
{
if((in[i]>96&&in[i]<123)||(in[i]>64&&in[i]<91))
{
out[j]=in[i];
++j;
}
else if(in[i]!=')')
pop(in[i],&top,stack);
else if(in[i]==')')
{
while(top>-1)
{
ch=push(&top,stack);
if(ch!='(')
{
out[j]=ch;
++j;
}
}
}
}
print(out);
print(stack);
getch();
return 0;
}
//*************************************
void pop(char x,int* up,char *stack)
{
*up+=1;
if(*up>49)
cout<<"Sorry Stack Is Full";
else
stack[*up]=x;
}
//*************************************
char push(int *up,char *stack)
{
if(*up<0)
cout<<"\nSorry Stack Is Empety\n\n";
else
*up-=1;
return stack[*up+1];
}
//*************************************
void print(char*s)
{
for(int i=0;i<50;i++)
if(s[i])
cout<<s[i];
}
این برنامه عبارت میانوندی را که با پارانتز اولویت بندی شده را میگیرد و ان را به یک عبارت پسوندی تبدیل می کند.

karma
10-24-2008, 08:05 PM
#include <iostream>
#include <conio>
#include <fstream>
#include <algorithm>
#include <stdio>
#include <stdlib>
# define esc 27
#define enter 13
#define up 72
#define down 80
#define tab 9
class library
{
public:
struct book
{
char name[20];
char writer[20];
char date[15];
char publisher[20];
char subject[20];
int id,price;
}book1,booktemp;
int menu();
char addmenu(int *,char *);
void add();
void searchmenu(int *,char *);
void search();
void show(int*,char*,char *);
void deletmenu(char *);
void delet();
}book;
//***********************main*********************** ****************************
int main()
{
while(1)
{
window(1,1,80,25);
textbackground(0);
textcolor(15);
clrscr();
gotoxy(29,3);
cprintf("WELCOM TO MY LIBRARY");
gotoxy(55,23);
cprintf("*** SPRING OF 1387 **");
int select=book.menu();
switch(select)
{
case 1:book.add();break;
case 2:book.search();break;
case 3:book.delet();
case 4:
cout<<"\a";
window(10,5,70,20);
textbackground(1);
textcolor(15);
clrscr();
gotoxy(15,7);
cprintf("ARE YOU SURE (y/n)?");
char ex=getch();
if(ex==13||ex==121||ex==89)
return 0;
}
}
return 0;
}
//******************************functions*********** ****************************
int library::menu()
{
char item[4][20]={
"1->Insert","2->Search","3->Delet","4->Exit"},key;
int i=0,j=0;
window(10,5,70,20);
textbackground(3);
clrscr();
window(1,1,25,80);
while(1)
{
for(i=0;i<4;i++)
{
textbackground(3);
textcolor(14);
if(i==j)
{
textbackground(1);
textcolor(15);
}
gotoxy(2,2+(2*i));
cprintf("%s",item[i]);
}
gotoxy(2,2+(2*j));
key=getch();
switch(key)
{
case 49:j=0;break;
case 50:j=1;break;
case 51:j=2;break;
case 52:j=3;break;
case up:if(j==0)j=3;else j--;break;
case down:if(j==3)j=0;else j++;break;
case tab:if(j==3)j=0;else j++;break;
case enter:break;
case esc:return 4;
}
if(key==13)break;
}
return j+1;
}
//*****************************************
char library::addmenu(int *j,char *key)
{
char add[7][20]={
"Name :","Writer :","Date publisher :","Price :","publisher :","Subject :","Code:"};
int i,flag=0;
window(21,5,50,20);
textbackground(1);
clrscr();
while(1)
{
for(i=0;i<7;i++)
{
textbackground(1);
textcolor(14);
if(i==*j)
{
textbackground(3);
textcolor(15);
}
gotoxy(2,2+(2*i));
cprintf("%s",add[i]);
}
gotoxy(2,2+(2*(*j)));
*key=getch();
switch(*key)
{
case up:if(*j==0)*j=6;else (*j)--;break;
case down:if(*j==6)*j=0;else (*j)++;break;
case tab:if(*j==6)*j=0;else (*j)++;break;
case enter:break;
case esc:break;
}
if(*key==13||*key==27)break;
}
}
//************************************************** **
void library::add()
{
char add[7][20]={
"Name :","Writer :","Date publisher :","Price :","publisher :","Subject :","Code:"},key;
int j=0;
char ch=addmenu(&j,&key);
ofstream file1("C:\\library.dat",ios::app);
if(!file1) cout<<"\ncan not open file";
if(ch==13)
{
gotoxy(2,2+(2*j));textbackground(1);textcolor(14); cprintf("%s",add[j]);
gotoxy(2,2);textbackground(3);textcolor(15);cprint f("%s",add[0]);
gotoxy(8,2);cin.get(book1.name,20);cin.get();
gotoxy(10,4);cin.get(book1.writer,20);cin.get();
gotoxy(18,6);cin.get(book1.date,20);cin.get();
gotoxy(9,8);cin>>book1.price;cin.get();
gotoxy(13,10);cin.get(book1.publisher,20);cin.get( );
gotoxy(11,12);cin.get(book1.subject,20);cin.get();
gotoxy(7,14);cin>>book1.id;cin.get();
file1.write((char*)&book1,sizeof(struct book));
file1.close();
}
}
//************************************************** ******
void library::searchmenu(int*j,char*key)
{
char add[3][20]={"Name :","subject :","Code:"};
int i,flag=0;
window(21,7,50,15);
textbackground(1);
clrscr();
while(1)
{
for(i=0;i<3;i++)
{
textbackground(1);
textcolor(14);
if(i==*j)
{
textbackground(3);
textcolor(15);
}
gotoxy(2,2+(2*i));
cprintf("%s",add[i]);
}
gotoxy(2,2+(2*(*j)));
*key=getch();
switch(*key)
{
case up:if(*j==0)*j=2;else (*j)--;break;
case down:if(*j==2)*j=0;else (*j)++;break;
case tab:if(*j==2)*j=0;else (*j)++;break;
case enter:break;
case esc:break;
}
if(*key==13||*key==27)break;
}
}
//************************************************** ***********
void library::search ()
{
char add[3][20]={"Name :","subject :","Code:"},ch,n[20];
int i,j,cod;
searchmenu(&j,&ch);
if(ch!=27)
{
switch(j)
{
case 0:gotoxy(8,2);cin.get(n,20);cin.get();i=1;break;
case 1:gotoxy(11,4);cin.get(n,20);cin.get();i=2;break;
case 2:gotoxy(7,6);cin.get(n,20);cin.get();i=3;break;
}
}
int x=atol(n);
show(&x,n,&ch);
}
//************************************************** ***********
void library::show(int *x,char*n,char *ch)
{
char item[7][20]={
"Name :",
"Writer :",
"Date publisher :",
"Price :",
"publisher :",
"Subject :",
"Code:"
};
if(*ch!=27)
{
ifstream file1("C:\\library.dat",ios::out);
if(!file1) cout<<"\ncan not open file";
int j=0;
if((*x)>0) while(file1.read((char*)&book1,sizeof(struct book)))
if(*x==book1.id)
{
j=1;
booktemp=book1;
break;
}
if(*x==0) while(file1.read((char*)&book1,sizeof(struct book)))
if(strcmp(book1.name,n)==0||strcmp(book1.subject,n )==0)
{
j=1;
booktemp=book1;
break;
}
file1.close();
window(10,5,70,20);
textbackground(6);
clrscr();
if(j==0)
{
textcolor(1);
gotoxy(6,7);
cprintf("!!! NOT FOUND THIS BOOK IN THE LIBRARY !!!");
gotoxy(15,10);
cprintf("PRESS ANY KEY TO COMTINUE :");
}
else
{
for(int i=0;i<7;i++)
{
textcolor(1);
gotoxy(2,(i+1)*2);
cprintf("%s",item[i]);
}
gotoxy(8,2);cprintf("%s",book1.name);
gotoxy(10,4);cprintf("%s",book1.writer);
gotoxy(18,6);cprintf("%s",book1.date);
gotoxy(9,8);cout<<book1.price;
gotoxy(13,10);cprintf("%s",book1.publisher);
gotoxy(11,12);cprintf("%s",book1.subject);
gotoxy(7,14);cout<<book1.id;
}
getch();
}
}
//**********************************************
void library::deletmenu(char *key)
{
window(20,9,35,11);
textbackground(1);
textcolor(14);
clrscr();
textcolor(15);
textbackground(3);
gotoxy(2,2);cprintf("Book code :");
gotoxy(2,2);
*key=getch();
}
//********************************
void library::delet()
{
char add[7][20]={
"Name :",
"Writer :",
"Date publisher :",
"Price :","publisher :",
"Subject :",
"Code:"};
char ch;
int code,i,f;
ofstream file2("C:\\temp.dat",ios::in);
if(!file2) cout<<"\ncan not open file";
ifstream file1("C:\\library.dat",ios::out);
if(!file1) cout<<"\ncan not open file";
deletmenu(&ch);
if(ch!=27)
{
gotoxy(13,2);
cin>>code;
}
while(file1.read((char*)&book1,sizeof(struct book)))
{
if(book1.id!=code)
file2.write((char*)&book1,sizeof(struct book));
if(book1.id==code)
{
window(10,5,70,22);
textbackground(1);
textcolor(15);
clrscr();
gotoxy(10,2);cprintf("PLEASE ENTER NEW INFORMATION OF BOOK");cin.get();
gotoxy(2,4);cprintf("%s",add[0]);cin.get(booktemp.name,20);cin.get();
gotoxy(2,6);cprintf("%s",add[1]);cin.get(booktemp.writer,20);cin.get();
gotoxy(2,8);cprintf("%s",add[2]);cin.get(booktemp.date,20);cin.get();
gotoxy(2,10);cprintf("%s",add[3]);cin>>booktemp.price;cin.get();
gotoxy(2,12);cprintf("%s",add[4]);cin.get(booktemp.publisher,20);cin.get();
gotoxy(2,14);cprintf("%s",add[5]);cin.get(booktemp.subject,20);cin.get();
gotoxy(2,16);cprintf("%s",add[6]);cin>>booktemp.id;cin.get();
file2.write((char*)&booktemp,sizeof(struct book));
}
}//end of while
file1.close();
file2.close();
remove("C:\\library.dat");
rename("C:\\temp.dat","C:\\library.dat");
}

pnugirl
10-24-2008, 11:51 PM
یه برنامه هم بذارین که بتونه گراف رو وارد کنه

karma
10-25-2008, 05:19 PM
#include <iostream>
#include <conio>
void print(int[][100],int);
void p();
int v,i,j,e[100][100];
char ch;
int main()
{
p();
cout<<"\n\nPlease enter the number of V:";
cin>>v;
while(1)
{
clrscr();
p();
cout<<"\n\nWhat do you want to do?\n\n";
cout<<"1-Insert a new Yal\n2-Delete a Yal\n3-Print Graph\n4-Exit\n\n";
cout<<"What is Your selection:";
cin>>ch;
switch(ch)
{
case'1':
clrscr();
p();
cout<<"\n\nplease enter Yal:";
cin>>i>>j;
if(i>v||j>v)
{
cout<<"\n\nWarning!!! you must enter two number betwen 0-"<<v;
getch();
}
else
e[i][j]=1;
break;
case'2':
clrscr();
p();
print(e,v);
cout<<"\n\nplease enter your Deleted Yal:";
cin>>i>>j;
e[i][j]=0;
break;
case'3':
print(e,v);
getch();
break;
case'4':return 0;
}
}
getch();
return 0;
}
//************************************************** *******
void print(int graph[][100],int v)
{
int i,j;
clrscr();
p();
cout<<"\n";
for(i=0;i<v;i++)
{
cout<<i<<" ";
for(j=0;j<v;j++)
{
cout<<graph[i][j]<<" ";
}
cout<<"\n";
}
cout<<"\n ";
for(i=0;i<v;i++)
cout<<i<<" ";
cout<<"\n\nV(G)={";
for(i=0;i<v;i++)
{
cout<<i;
if(i<v-1)
cout<<",";
}
cout<<"}";
cout<<"\n\nE(G)={";
for(i=0;i<v;i++)
{
for(j=0;j<v;j++)
{
if(graph[i][j]==1)
cout<<"("<<i<<","<<j<<")";
}
}
cout<<"}";
}
//************************************************** *******
void p()
{
gotoxy(55,23);
cout<<"*** Writing By Hossein ***";
gotoxy(1,1);
}
این برنامه ابتدا یک عدد را بعنوان تعداد رئوس از شما میگیره و سپس بسته به انتخاب خودتون می تونید یال به آن اضافه یا از آن حذف کنید.

sunyboy
10-25-2008, 06:39 PM
اين برنامه به روش ضرب متني عمل ميكنه كه در سورس طول حاصلضرب 5000 رقم فرض شده كه مي تونيد بيشتر بذاريد





#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
char s[5000];
void pp(int n);
void main()
{
clrscr();
long int i,k,m;
printf("enter number:\t");
scanf(" %ld",&m);
itoa(1, s, 10);
for(i=1;i<=m;++i){
pp(i);
}
k=strlen(s);
for(i=k;i>=0;--i)
printf("%c",s[i]);
getch();
}
////////////////
void pp(int n){
long int r,i,j,k,l;
r=0;
for(i=0;s[i]!='\0';++i){
k=(s[i]-48)*n+r;
l=k-(k/10)*10;
s[i]=l+48;
r=k/10;
}
for(j=i;r>0;++j){
l=r-(r/10)*10;
s[j]=l+48;
r=r/10;
}
s[j+1]='\0';
}

sunyboy
10-25-2008, 06:41 PM
یه نوشته تو صفحه حرکت میکنه در حالی که دائم رنگش عوض میشه... اگه به گوشه های تصویر خورد برمیگره....




*****************************/
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <stdlib.h>
void main()
{
int random_y1,random_y2,random_x1,random_x2,w_x,w_y,x, y;
clrscr();
randomize();

do /***** Begin Loop *****/
{
w_x=wherex()-3;
w_y=wherey();
clrscr();
gotoxy(w_x+x,w_y+y);
textcolor(1+random(3));
printf("www.forum.daneshjuha.org");
/******** if text wherex=0 ********/
if (wherex()<=7)
{
sound(200);
random_x1=random(2);

if (random_x1==1)
{x=1;y=1;}
if (random_x1==0)
{x=1;y=-1;}
}
/******** if text wherex=80 ********/
if (wherex()>=78)
{
sound(500);
random_x2=random(2);

if (random_x2==1)
{x=-1;y=-1;}
if (random_x2==0)
{x=-1;y=-1;}
}

/******** if text wherey=0 ********/
if (wherey()==1)
{
sound(800);
random_y1=random(2);

if (random_y1==1)
{y=1;x=-1;}
if (random_y1==0)
{y=1;x=1;}
}
/******** if text wherey=25 ********/
if (wherey()==25)
{
sound(1200);
random_y2=random(2);

if (random_y2==1)
{y=-1;x=-1;}
if (random_y2==0)
{y=-1;x=1;}
}
delay(190);
nosound();
kbhit();
}
while(!kbhit());/***** End Loop *****/
} __________________

sunyboy
10-25-2008, 06:43 PM
یک منو رسم میکنه که 3تا گزینه داره که هر کدوم یه رنگه و با زدن هر گزینه رنگ پس زمینه عوض میشه.....







#include <stdio.h>
#include <conio.h>
f_lines();
up_key();
down_key();
void main()
{
int i;
char c1,c2;
textbackground(0);
gotoxy(wherex(),11);
f_lines();
do
{
c1=getch();

/*******if insert ENTER key*******/
if (c1==13)
{
if (wherey()==19)
{
textbackground(2);
f_lines();

}

if (wherey()==15)
{
textbackground(1);
f_lines();

}

if (wherey()==11)
{
textbackground(4);
f_lines();

}

}
/*******if insert UP key*******/
if (c1==0)
{
c2=getch();
if (((c1==0) && (c2==72)))
{
up_key();
}
/*******if insert DOWN key*******/
if (((c1==0) && (c2==80)))
{
down_key();
}
}
}while(c1!=27);

}



/***********( FUNCTION )**********/
f_lines()
{
int w,i;
w=wherey();
textcolor(15);
clrscr();
printf("%c",201);
for (i=0; i<78; i++)
{
printf("%c",205);
}
printf("%c",187);
for (i=0; i<23; i++)
{ printf("%c\n",186); }
printf("%c",200);
for (i=0; i<77; i++)
{
printf("%c",205);
}
printf("%c",188);
for (i=2; i<25; i++)
{ gotoxy(80,i);
printf("%c",186); }
/*************** Drow KEY ****************/


/******* Red key *******/
gotoxy(34,9);
printf("%c%c%c%c%c%c%c%c%c%c%c%c",201,205,205,205,205,205,205,205,205,205,205,187);
gotoxy(34,10);
printf("%c RED %c",186,186);
gotoxy(34,11);
printf("%c%c%c%c%c%c%c%c%c%c%c%c",200,205,205,205,205,205,205,205,205,205,205,188);

/******* Blue key *******/
gotoxy(34,13);
printf("%c%c%c%c%c%c%c%c%c%c%c%c",201,205,205,205,205,205,205,205,205,205,205,187);
gotoxy(34,14);
printf("%c Blue %c",186,186);
gotoxy(34,15);
printf("%c%c%c%c%c%c%c%c%c%c%c%c",200,205,205,205,205,205,205,205,205,205,205,188);
/******* Green key *******/
gotoxy(34,17);
printf("%c%c%c%c%c%c%c%c%c%c%c%c",201,205,205,205,205,205,205,205,205,205,205,187);
gotoxy(34,18);
printf("%c Green %c",186,186);
gotoxy(34,19);
printf("%c%c%c%c%c%c%c%c%c%c%c%c",200,205,205,205,205,205,205,205,205,205,205,188);
gotoxy(wherex(),w);
}


up_key()
{
if ((wherey()==19) || (wherey()==15))
{
int k;
k=wherey()-4;
gotoxy(wherex(),k);
}
}



down_key()
{
if ((wherey()==15) || (wherey()==11))
{
int k;
k=wherey()+4;
gotoxy(wherex(),k);
}
}

sunyboy
10-25-2008, 06:47 PM
این برنامه تحت ++Turbo c اجرا میشه و به صورت خیلی ساده کار کردن با کلیدهای مکان نما را در ++ c برای حرکت دادن اشیا نشون میده.




#include <graphics.h>
#include <conio.h>
#include <iostream.h>
#define RIGHT 0x4d /* define keyboard arrow keys */
#define LEFT 0x4b
#define DOWN 0x50
#define UP 0x48
#define ENTER 13
void draw( int, int);
int main(void)
{
int gdriver = DETECT, gmode, errorcode;

initgraph(&gdriver, &gmode, "C:\\tc\\bgi\\");

int x, y;
char c;
x = 50;
y = 300;
setfillstyle(1,1);
circle(x,y,10);
floodfill(x+1,y+1, getmaxcolor());
do
{
c = getch();
if ( c == UP )
{
y-=1;
draw(x, y);
}
if ( c == DOWN )
{
y+=1;
draw(x, y);
}
if ( c == RIGHT )
{
x+=1;
draw(x, y);
}
if ( c == LEFT )
{
x-=1;
draw(x, y);
}
if ( c == ENTER )
{
for ( int i = x; i < getmaxx()+10; i++)
draw( i, y);
}
}while( c != ENTER );
getch();
closegraph();
return 0;
}

void draw( int x , int y)
{
cleardevice();
setfillstyle(SOLID_FILL,BLUE);
circle(x,y,10);
floodfill(x+1,y+1,getmaxcolor());
}

sunyboy
10-25-2008, 06:51 PM
یک برنامه کوچک و جالب برای تمرین توابع گرافیکی در Turbo c++




#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <time.h>
#include <dos.h>

int main(void)
{
int gdriver = DETECT, gmode, errorcode;

initgraph(&gdriver, &gmode, "C:\\tc\\bgi\\");

int x, y, maxx, maxy, color;

maxx = getmaxx();
maxy = getmaxy();

srand( time ( 0 ) );
for ( int i = 0; i < 500; i++ )
{
if(kbhit()) break;
x = rand() % maxx;
y = rand() % maxy;
color = rand() % 12;
setcolor(color);
for (int xx = 0, yy = 10; xx <= 360; xx+= 5, yy += 5 )
{
pieslice ( x, y, xx, yy, 10);
delay(10);
}
}
getch();
closegraph();
return 0;
}

sunyboy
10-25-2008, 06:53 PM
برنامه ای برای بدست آوردن دترمینان یک ماتریس n در n




#include <iostream.h>
#include <conio.h>
int calc(int [],int dim);
void revmatrix( int [],int dim);
void main()
{
int matrix[1000];
int dim,temp;
double leftsum,rightsum;
cout<<" PLEASE ENTER MATRIX DIMENSION : ";
cin>>dim;
cout<<"\n\n\n";
for( int i = 0;i<( dim*dim );i ++ )
{
cout<<"ENTER ELEMAN : ";
cin>>temp;
matrix[i] = temp;
clrscr();
cout<<" PLEASE ENTER MATRIX DIMANTION : "<<dim;
cout<<"\n\n\n";
}//for i

if ( dim > 2 )
{
leftsum = calc( matrix , dim );
cout<<"LEFTSUM of the matrix = "<< leftsum <<"\n\n";
revmatrix( matrix , dim );
rightsum = calc( matrix ,dim );
cout<<"RIGHTSUM of the matrix = "<< rightsum <<"\n\n\n\n\n\n" ;
cout<<" ( DETERMINAN OF THE MATRIX = "<< leftsum - rightsum<<" )";
}

else
cout<<" ( DETERMINAN OF THE MATRIX = "<<(matrix[0] * matrix[3] - matrix[1] * matrix[2])<<" )";

getch();
}//end main

/////////////////calc function//////////

int calc( int matrix[ ], int dim )
{
int sum = 0, bul, x = 1;
for( int l = 0; l<( dim*dim );l += ( dim+1 ) )//ghotr asli
x *= matrix[l];
sum = x;
x = 1;
for( int c = 1;c<dim;c ++ )
{
bul=c;
for( int m = 0;m<dim;m ++ )
{
if( ( bul+1 )%dim != 0 )
{
x *= matrix[bul];
bul +=( dim + 1 );
}

else
{
x = x * matrix[bul];
bul += 1;
}

}//for m
sum += x;
x = 1;
}//for c

return sum;
}

////////////////////revmatriv determinan

void revmatrix(int matrix[ ],int dim)
{
int end,temp,counter;
for( int t = dim-1;t <= dim*dim;t = t + dim )


{
end=t;
counter = end -( dim-1 );
while( end > counter )
{
temp = matrix[end];
matrix[end] = matrix[counter];
matrix[counter] = temp;
++ counter;
-- end;
}

}
}

sunyboy
10-25-2008, 06:55 PM
#include <conio.h>
#include<stdio.h>
#include<graphics.h>
#include<dos.h>
#include<string.h>
#include <stdlib.h>
static int xb1=20, yb1=50, zb1=30, clb1=9;
static int xb2=120, yb2=yb1, zb2=zb1, clb2=15;
static int xb3=220,yb3=yb1, zb3=zb1, clb3=4;
static int xb4=320, yb4=yb1, zb4=zb1, clb4=5;
static int xb5=420, yb5=yb1, zb5=zb1, clb5=10;
static int x=30,y=450,z=10;
static int db=0,mi=2;
int ow=0,wo=0,to=0,ot=0,wot=0;
char a;
static char skol[50],sb_1[]={"hego"},sb_2[]={"hegoby"},sb_3[]={"hegobybus"},sb_4[]={"hegobybuseveryday"};
char sb1[]={"he"}, sb2[]={"go"}, sb3[]={"by"},sb4[]={"bus"},sb5[]={"everyday"};
void tank(int x,int y,int z);
void movetank(char a);
void shoottank(char a);
void balon(int a,int b,int c,int cl,char s[]);
void movebalon();
void start();
void finish();
void tank(int x,int y,int z)
{
circle(x,y,z);
rectangle(x-15,y,x+15,y+20);
circle(x-15,y,z/2);
circle(x+15,y,z/2);
rectangle(x-20,y-z,x-15,y);
rectangle(x+20,y-z,x+15,y);
rectangle(x-3,y-(z+8),x+3,y);
}
void movetank(char key)
{
if (key==77)
{
setcolor(0);
tank(x,y,z);
x+=5;
setcolor(15);
tank(x,y,z);
}
if (key==75)
{
setcolor(0);
tank(x,y,z);
x-=5;
setcolor(15);
tank(x,y,z);
}
else return;
}
void shoottank(char key)
{
int k;
k=y-20;
if (key==32){
while(k>0){
putpixel(x,k-=1,3);
delay(1);
putpixel(x,k,0);
if (getpixel(x,k-1)==9)
{ clb1=0;
balon(xb1,yb1,zb1,clb1,sb1);
strcat(skol,sb1);
printf(sb1);
ow=1;
}
if (getpixel(x,k-1)==15)
{ clb2=0;
balon(xb2,yb2,zb2,clb2,sb2);
strcat(skol,sb2);
printf(sb2);
wo=1;
}
if (getpixel(x,k-1)==4)
{ clb3=0;
balon(xb3,yb3,zb3,clb3,sb3);
strcat(skol,sb3);
printf(sb3);
to=1;
}
if (getpixel(x,k-1)==5)
{ clb4=0;
balon(xb4,yb4,zb4,clb4,sb4);
strcat(skol,sb4);
printf(sb4);
ot=1;
}
if (getpixel(x,k-1)==10)
{ clb5=0;
balon(xb5,yb5,zb5,clb5,sb5);
strcat(skol,sb5);
printf(sb5);
wot=1;
}
if (wo+ow==2&&mi==2)
{
setcolor(0);
cleardevice();
if (!strcmp(sb_1,skol)) {
settextstyle(3,0,50);
setcolor(15);
outtextxy(80,100,"YOU WIN ...");
delay(2000);
db=1;
return;
}
if(strcmp(sb_1,skol)) {
settextstyle(3,0,50);
setcolor(15);
outtextxy(50,100,"YOU LOSS ...");
delay(2000);
db=0;
return;
}
}
if (wo+ow+to==3&&mi==3)
{
setcolor(0);
cleardevice();
if (!strcmp(sb_2,skol)) {
settextstyle(3,0,50);
setcolor(15);
outtextxy(80,100,"YOU WIN ...");
delay(2000);
db=1;
return;
}
if(strcmp(sb_2,skol)) {
settextstyle(3,0,50);
setcolor(15);
outtextxy(50,100,"YOU LOSS ...");
delay(2000);
db=0;
return;
}
}
if (wo+ow+to+ot==4&&mi==4)
{
setcolor(0);
cleardevice();
if (!strcmp(sb_3,skol)) {
settextstyle(3,0,50);
setcolor(15);
outtextxy(80,100,"YOU WIN ...");
delay(2000);
db=1;
return;
}
if(strcmp(sb_3,skol)) {
settextstyle(3,0,50);
setcolor(15);
outtextxy(50,100,"YOU LOSS ...");
delay(2000);
db=0;
return;
}
}
if (wo+ow+to+ot+wot==5&&mi==5)
{
setcolor(0);
cleardevice();
if (!strcmp(sb_4,skol)) {
settextstyle(3,0,50);
setcolor(15);
outtextxy(80,100,"YOU WIN ...");
delay(2000);
db=1;
return;
}
if(strcmp(sb_4,skol)) {
settextstyle(3,0,50);
setcolor(15);
outtextxy(50,100,"YOU LOSS ...");
delay(2000);
db=0;
return;
}
}
}}}
void balon(int a,int b,int c,int cl,char s[])
{
setcolor(cl);
settextstyle(0,0,1);
circle(a,b,c);
rectangle(a-(c-5),b+(2*c),a+(c-5),b+(2*c)+50);
line(a-c,b,a-(c-5),b+(2*c));
line(a+c,b,a+(c-5),b+(2*c));
moveto(a-(c-5)+2,b+(2*c)+10);
outtext(s);
}
void movebalon(int a)
{
if (xb1==a)
{
if (xb1<640)
{
balon(xb1,yb1,zb1,0,sb1);
xb1+=1;
balon(xb1,yb1,zb1,clb1,sb1);
}
else {balon(xb1,yb1,zb1,0,sb1);
xb1=50;}
}
if (a==xb2)
{
if (xb2<640)
{
balon(xb2,yb2,zb2,0,sb2);
xb2+=1;
balon(xb2,yb2,zb2,clb2,sb2);
}
else {balon(xb2,yb2,zb2,0,sb2);
xb2=50;}
}
if (a==xb3)
if (mi==3||mi==4||mi==5)
{
if (xb3<640)
{
balon(xb3,yb3,zb3,0,sb3);
xb3+=1;
balon(xb3,yb3,zb3,clb3,sb3);
}
else {balon(xb3,yb3,zb3,0,sb3);
xb3=50;}
}
if (xb4==a)
if(mi==4||mi==5)
{
if (xb4<640)
{
balon(xb4,yb4,zb4,0,sb4);
xb4+=1;
balon(xb4,yb4,zb4,clb4,sb4);
}
else {balon(xb4,yb4,zb4,0,sb4);
xb4=50;}
}
if (xb5==a)
if (mi==5){
if (xb5<640)
{
balon(xb5,yb5,zb5,0,sb5);
xb5+=1;
balon(xb5,yb5,zb5,clb5,sb5);
}
else {balon(xb5,yb5,zb5,0,sb5);
xb5=50;}
}
}
void start()
{
int iop=1;
setcolor(15);
settextstyle(2,0,10);
outtextxy(100,100,"DESIGN BY:");
for(iop=1;iop<16;iop++) {
setcolor(iop);
settextstyle(3,0,8);
outtextxy(100,250,"OMID SISTANI");
delay(200);}
setcolor(0);
cleardevice();
setcolor(15);
while(!kbhit()){
settextstyle(2,0,8);
outtextxy(80,50,"INFORMATION ABOUT THIS GAME:");
outtextxy(80,100,"MOVE TO RIGHT: RIGHT key");
outtextxy(80,150,"MOVE TO LEFT: LEFT key");
outtextxy(80,200,"FIRE TANK: SPACE key");
outtextxy(80,250,"EXIT THE GAME: q key");
outtextxy(80,300,"YOU HAD MAKE THIS MESSAGE:");
settextstyle(3,0,5);
outtextxy(80,400,"HE GO BY BUS EVERYDAY");
}
setcolor(0);
cleardevice();
setcolor(15);
settextstyle(3,0,6);
outtextxy(1,150,"ARE YOU READY...");
delay(2000);
setcolor(0);
cleardevice();
setcolor(15);
}
void finish()
{
int op=1;
while (!kbhit())
{
setcolor(0);
cleardevice();
setcolor(op);
settextstyle(3,0,8);
outtextxy(100,100,"YOU FINISH");
outtextxy(100,300,"THIS GAME");
op++;
delay(100);
}}
void next()
{
strcpy(skol,"");
xb1=20, yb1=50, zb1=30, clb1=9;
xb2=120, yb2=yb1, zb2=zb1, clb2=15;
xb3=220,yb3=yb1, zb3=zb1, clb3=4;
xb4=320, yb4=yb1, zb4=zb1, clb4=5;
xb5=420, yb5=yb1, zb5=zb1, clb5=10;
setcolor(15);
x=30,y=450,z=10;
settextstyle(3,0,8);
setcolor(0);
cleardevice();
setcolor(15);
outtextxy(60,150,"NEXT MISSION");
delay(2000);
setcolor(0);
cleardevice();
setcolor(15);
tank(x,y,z);
}
void main()
{
int gd=DETECT,gm=0;
initgraph(&gd,&gm,"c:\\tc\\bgi");
start();
tank(x,y,z);
balon(xb1,yb1,zb1,clb1,sb1);
balon(xb2,yb2,zb2,clb2,sb2);
while(a!='q'){
while (!kbhit()){
delay(100);
movebalon(xb2);
movebalon(xb1); }
a=getch();
movetank(a);
shoottank(a);
if (wo+ow==2){if(db==1) {getch(); break;}
else{getch(); exit(1);} }
}
if (db==1){
ow=0;wo=0;to=0;
db=0;mi=3;
next();}
else exit(1);
while(a!='q'){
while (!kbhit()){
delay(100);
movebalon(xb3);
movebalon(xb2);
movebalon(xb1); }
a=getch();
movetank(a);
shoottank(a);
if (wo+ow+to==3){if(db==1) {getch(); break;}
else{getch(); exit(1);} }
}
if (db==1){ow=0;wo=0;to=0;
db=0;mi=4;
next();}
else exit(1);
while(a!='q'){
while (!kbhit()){
delay(100);
movebalon(xb4);
movebalon(xb3);
movebalon(xb2);
movebalon(xb1); }
a=getch();
movetank(a);
shoottank(a);
if (wo+ow+to+ot==4){if(db==1) {getch(); break;}
else{getch(); exit(1);} }
}
if (db==1){
ow=0;wo=0;to=0;ot=0;
db=0;mi=5;
next();}
else exit(1);
while(a!='q'){
while (!kbhit()){
delay(100);
movebalon(xb5);
movebalon(xb4);
movebalon(xb3);
movebalon(xb2);
movebalon(xb1); }
a=getch();
movetank(a);
shoottank(a);
if (wo+ow+to+ot+wot==5){if(db==1) {getch(); break;}
else{getch(); exit(1);} }
}
if (db==1) finish();
else exit(1);
closegraph();
}

sunyboy
10-25-2008, 07:04 PM
برنامه اینه که یه گرامر و یک رشته می گیره و میگه که گرامر وارد شده رشته وارد شده را قبول می کنه یا نه




#include<conio.h>
#include<stdio.h>
#include<dos.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#include<graphics.h>

void split(char *,char *,int ,int);

int main()
{

struct str
{
char c1;
char s[10];
char c2;
} str1[10],str2;

int t,n,i,j=0,a,l,test=0,ch=0,flag1=0;
char string[20],string1[10],c3,c4,c5,gram[5];
char m,k,f,temp,flag,gg,tr,Enter ,ff;
clrscr();
//************************************************** ***************
textbackground(9);
clrscr(); //WEL COME
textcolor(2);
printf("\n\n\n\n");
cprintf(" Wel Come ");
printf("\n\n");
textcolor(4);
cprintf(" ================================");
delay(1000);

//************************************************** ***************

ff:
printf("\n\n\n\n\n");
textcolor(6);
cprintf(" Please Enter Number of line grammer : ");

scanf("%d",&n);
printf("\n ***************************************\n");
printf("\n\n Please Enter Grammer (to form S__c1..cnB) : \n\n ");
for(i=0;i<n;i++){
t=0;
scanf("%c",&str1[i].c1);
scanf("%c%c%c",&c3,&c4,&c5);
printf(" \n");
str1[i].c1=c3;
// ************************************************** ******************
//spllit line of gramer
m='a';
while(1)
if(toascii(m)>96 && toascii(m)<123 )
{
scanf("%c",&m);
str1[i].s[t]=m;
t++;
}
else
{
str1[i].s[--t]='\0';
str1[i].c2=m;
break;
}

if(toascii(str1[i].c2)>97 && toascii(str1[i].c2)<65)
{
printf("\n NOT : Please Enter Grammer (to form A__c1..cnB) \n");
getch();
exit(1);
}
} // End for

if(str1[0].c1!='S')
{
printf("\n ERROR !! Enter grammer to form S__c1..cnB .\n");
goto ff;
}
gg:
clrscr();
printf("\n\n\n Your Grammer Is : ");
printf("\n _________________\n\n");
for(i=0;i<n;i++)
printf("\n %c==>%s%c \n",str1[i].c1,str1[i].s,str1[i].c2);
printf("\n\n ********************************\n");
printf("\n\n\n Please enter a string for test : ");
scanf("%s",string);

//************************************************** *******************
//check kardane sehat khat aval grammer
l=strlen(str1[0].s);
split(string,string1,0,l);
flag='f';

for(i=0;i<n;i++)
if (strcmp(string1,str1[i].s)==0)
{
tr=str1[i].c2;
flag='t';
}// End For

if(flag=='f')
{
printf(" \n\n This String Not Accept!");
printf(" \n\n\n\n\n\n Continue(Press ENTER) / Exit(Press Q/q) : ");
Enter=getch();
if(Enter=='q' || Enter=='Q') exit(1);
goto gg;
}

//************************************************** ****************
for(i=0;i<n;i++)
if(tr==str1[i].c1 && str1[i].c2=='L'&& strlen(string1)==strlen(string))
{
flag1=1;
printf("\n\n This String Accept \n");
printf(" \n\n\n\n\n\n Continue(Press ENTER) / Exit(Press Q/q) : ");
Enter=getch();
if(Enter=='q' || Enter=='Q') exit(1);
goto gg;
}

if(flag1==0 && strlen(string1)==strlen(string))
{
printf("\n\n This String Not Accept \n");
printf(" \n\n\n\n\n\n Continue(Press ENTER) / Exit(Press Q/q) : ");
Enter=getch();
if(Enter=='q' || Enter=='Q') exit(1);
goto gg;
}
//************************************************** *******************
// shoroa amaliat baraye sehat ya rad reshre

if (strcmp(string1,str1[0].s)==0)
{
j=l;
temp=str1[0].c2;

while(string[j])
{
ch=0;
for(i=0;i<n;i++)
{
l=strlen(str1[i].s);
split(string,string1,j,l);
if((strcmp(string1,str1[i].s)==0)&&(str1[i].c1==temp))
{
ch=1;
temp=str1[i].c2;
j=j+l;
break;
} // /end if


} // end for i

if(ch==0)
{
printf("\n\n This String Not Accept!");
printf(" \n\n\n\n\n\n Continue(Press ENTER) / Exit(Press Q/q) : ");
Enter=getch();
if(Enter=='q' || Enter=='Q') exit(1);
goto gg;
}

} // end while

for(j=0;j<n;j++)
if(str1[i].c2==str1[j].c1 && str1[j].c2=='L')
{
printf("\n\n This String Accept \n");
printf(" \n\n\n\n\n\n Continue(Press ENTER) / Exit(Press Q/q) : ");
Enter=getch();
if(Enter=='q' || Enter=='Q') exit(1);
goto gg;
}

for(j=0;j<n;j++)
if(str1[i].c2==str1[j].c1 && str1[j].c2!='L')
{
printf("\n\n This String Not Accept \n");
printf(" \n\n\n\n\n\n Continue(Press ENTER) / Exit(Press Q/q) : ");
Enter=getch();
if(Enter=='q' || Enter=='Q') exit(1);
goto gg;
}

if (ch=='t')
printf("\n\n This String Accept\n");

} // End main if
// closegraph();
getch();
return 0;
}
//************************************************** ********************
// FUNCTION SPLIT
void split(char str[20],char str1[10],int s,int l)
{
int i,j,len;
j=0;
len=s+l;
for(i=s;(i<len)&&(str[i]);i++)
{
str1[j]=str[i];
j++;
}
str1[j]='\0';
}

sunyboy
10-25-2008, 07:30 PM
بصورت متنی:





#include <stdio.h>
#include<process.h>
#include <dos.h>
#include<conio.h>
#include<stdio.h>

#define SIZE 5

static struct stack{
int top;
int items[SIZE];
}s1;

void push(struct stack *,int);
int pop(struct stack*);
int stacktop(struct stack*);
int empty(struct stack*);
int search(struct stack *,int);
void insert(struct stack *,int,int);
void replace(struct stack *,int,int);
void del(struct stack *,int);
void printline(void);

void main()
{
char c;
int i,temp;
s1.top=-1;
mark:
clrscr();
gotoxy(28,2);
printf("BASIC STACK OPERATIONS");
gotoxy(34,4); printf("(1) Push");
gotoxy(34,6); printf("(2) Pop");
gotoxy(34,8); printf("(3) Search");
gotoxy(34,10); printf("(4) Insert");
gotoxy(34,12); printf("(5) Replace");
gotoxy(34,14); printf("(6) Delete\n\n");
gotoxy(0,18); printline();
c=getch();
switch (c)
{
case '1': printf("\nWhat element do you wish to push?");
scanf("%d",&temp);
push(&s1,temp);
break;
case '2': pop(&s1);
break;
case '3': printf("\nEnter the element you wish to search?");
scanf("%d",&temp);
printf("\nThe element is at index %d\n",search(&s1,temp));
break;
case '4': printf("\nEnter the POSTION and ELEMENT you wish to insert?");
scanf("%d %d",&i,&temp);
insert(&s1,i,temp);
break;
case '5': printf("\nEnter the POSTION and ELEMENT you wish to replace?");
scanf("%d %d",&i,&temp);
replace(&s1,i,temp);
break;
case '6': printf("\nEnter the POSTION you wish to delete from stack?");
scanf("%d",&temp);
del(&s1,temp);
break;
default : printf("\nInvalid entry! Try again!");
break;
}
for (i=s1.top;i>=0;i--)
printf("\nThe element at position (%d) is %4d",i,s1.items[i]);
printf("\n\nDo you wish to continue?");
c=getch();
if (c=='y')
goto mark;
}

void push(struct stack *sx,int x)
{
if (sx->top==SIZE-1)
{
printf("\n\tSTACT OVERFLOW\n");
getch();
exit(1);
}
sx->items[++sx->top]=x;
}

int pop(struct stack *sx)
{
if (empty(sx))
{
printf("\n\t STACK UNDERFLOW\n");
getch();
exit(1);
}
return(sx->items[sx->top--]);
}

int stacktop(struct stack *sx)
{
return(sx->items[sx->top]);
}

int empty(struct stack *sx)
{
return((sx->top==-1));
}

int search(struct stack *sx,int n)
{
int arr[20];
int i=0,j,result=-1;
for (j=sx->top;!(empty(sx));j--)
{
if (n==stacktop(sx))
{
result=sx->top;
break;
}
arr[i++]=pop(sx);
}
for (j=i-1;j>=0;j--)
push(sx,arr[j]);
return(result);
}

void insert(struct stack *sx,int pos,int ele)
{
int arr[20];
int i=0,j;
for (j=sx->top;j>=pos;j--)
arr[i++]=pop(sx);
push(sx,ele);
for (j=i-1;j>=0;j--)
push(sx,arr[j]);
}

void replace(struct stack *sx,int pos,int ele)
{
int arr[20];
int i=0,j;
for (j=sx->top;j>=pos;j--)
arr[i++]=pop(sx);
push(sx,ele);
for (j=i-2;j>=0;j--)
push(sx,arr[j]);
}

void del(struct stack *sx,int pos)
{
int arr[20];
int i=0,j;
for (j=sx->top;j>pos;j--)
arr[i++]=pop(sx);
pop(sx);
for (j=i-1;j>=0;j--)
push(sx,arr[j]);
}

void printline(void)
{
int i;
for (i=0;i<40;i++)
printf("®¯");
}


بصورت گرافیکی:




#include <stdio.h>
#include <graphics.h>
#include <dos.h>
#include<conio.h>
#include<process.h>

#define SIZE 6

static struct stack{
int top;
int items[SIZE];
}s1;

void push(struct stack *,int);
int pop(struct stack*);
int stacktop(struct stack*);
int empty(struct stack*);
int search(struct stack *,int);
void insert(struct stack *,int,int);
void replace(struct stack *,int,int);
void del(struct stack *,int);
void printline(void);
void startscreen(int,int);
void shell(int,int);
void close(void);
void start_screen();
void press_esc();

int gd=DETECT,gm,maxx,maxy;


void main()
{
char c;
int i,temp;
s1.top=-1;
initgraph(&gd,&gm,"f:\\tc\\bgi");
maxx=getmaxx();
maxy=getmaxy();
startscreen(maxx,maxy);
start_screen();
shell(maxx,maxy);
START:
c=getch();
switch (c)
{
case '1': gotoxy(3,17);
printf("What element do you wish to push?");
scanf("%d",&temp);
push(&s1,temp);
break;
case '2': gotoxy(3,17);
pop(&s1);
break;
case '3': gotoxy(3,17);
printf("Enter the element you wish to search?");
scanf("%d",&temp);
temp=search(&s1,temp);
gotoxy(5,19);
if (temp==-1)
printf("Sorry! No results Found!");
else
printf("The element is at index %d",temp);
getch();
break;
case '4': gotoxy(3,17);
printf("Enter the POSTION and ELEMENT you wish to insert?");
scanf("%d %d",&i,&temp);
insert(&s1,i,temp);
break;
case '5': gotoxy(3,17);
printf("Enter the POSTION and ELEMENT you wish to replace?");
scanf("%d %d",&i,&temp);
replace(&s1,i,temp);
break;
case '6': gotoxy(3,17);
printf("Enter the POSTION you wish to delete from stack?");
scanf("%d",&temp);
del(&s1,temp);
break;
default : gotoxy(3,17);
printf("Invalid entry! Try again!");
break;
}
for (i=0;i<=6;i++)
{
gotoxy(3,17+i);
printf("\t\t\t\t\t\t\t\t\t");
}
gotoxy(3,17);
printf("Do You wish to contine?");
c=getch();
if (c=='y')
{
gotoxy(3,17); printf("\t\t\t\t\t");
goto START;
}
closegraph();
close();
restorecrtmode();
}

void push(struct stack *sx,int x)
{
if (sx->top==SIZE-1)
{
gotoxy(5,22);
printf("\tSTACT OVERFLOW\n");
getch();
return;
}
sx->items[++sx->top]=x;
gotoxy(66,14-2*sx->top);
printf("%d",x);
}

int pop(struct stack *sx)
{
if (empty(sx))
{
gotoxy(5,22);
printf("\t STACK UNDERFLOW\n");
getch();
return(0);
}
gotoxy(66,14-2*sx->top);
printf(" ");
return(sx->items[sx->top--]);
}

int stacktop(struct stack *sx)
{
return(sx->items[sx->top]);
}

int empty(struct stack *sx)
{
return((sx->top==-1));
}

int search(struct stack *sx,int n)
{
int arr[20];
int i=0,j,result=-1;
for (j=sx->top;!(empty(sx));j--)
{
if (n==stacktop(sx))
{
result=sx->top;
break;
}
arr[i++]=pop(sx);
}
for (j=i-1;j>=0;j--)
push(sx,arr[j]);
return(result);
}

void insert(struct stack *sx,int pos,int ele)
{
int arr[20];
int i=0,j;
if (pos>sx->top)
{
gotoxy(3,19);
printf("Invalid Position!");
getch();
return;
}
for (j=sx->top;j>=pos;j--)
arr[i++]=pop(sx);
push(sx,ele);
for (j=i-1;j>=0;j--)
push(sx,arr[j]);
}

void replace(struct stack *sx,int pos,int ele)
{
int arr[20];
int i=0,j;
if (pos>sx->top)
{
gotoxy(3,19);
printf("Invalid Position!");
getch();
return;
}
for (j=sx->top;j>=pos;j--)
arr[i++]=pop(sx);
push(sx,ele);
for (j=i-2;j>=0;j--)
push(sx,arr[j]);
}

void del(struct stack *sx,int pos)
{
int arr[20];
int i=0,j;
if (pos>sx->top)
{
gotoxy(3,19);
printf("Invalid Position!");
getch();
return;
}
for (j=sx->top;j>pos;j--)
arr[i++]=pop(sx);
pop(sx);
for (j=i-1;j>=0;j--)
push(sx,arr[j]);
}

void printline(void)
{
int i;
for (i=0;i<40;i++)
printf("®¯");
}

void startscreen(int x,int y)
{
int i;
sound(1);
setbkcolor(1);
setlinestyle(5,0,2);
rectangle(0,0,x,y);
rectangle(2,2,x-2,y-2);
settextstyle(10,HORIZ_DIR,3);
setcolor(YELLOW);
outtextxy(x/10,y/3,"Loading ....... Please Wait......");
setcolor(LIGHTGRAY);
rectangle(x/8,2*y/3,7*x/8,2*y/3+20);
setcolor(WHITE);
bar(x/8+1,2*y/3+1,7*x/8-1,2*y/3+20-1);
setfillstyle(1,LIGHTBLUE);
delay(2000);
for (i=4;i>=1;i--)
{
bar(x/8+1,2*y/3+1,7*x/8/i-1,2*y/3+20-1);
delay(1000);
}
delay(500);
nosound();
//closegraph();
initgraph(&gd,&gm,"f:\tc\bgi");
}

void shell(int x,int y)
{

int i;
setbkcolor(BLACK);
rectangle(0,0,x,y);
rectangle(2,2,x-2,y-2);
settextstyle(0,HORIZ_DIR,2);
gotoxy(18,2);
setcolor(WHITE);
outtextxy(x/5,y/30,"BASIC STACK OPERATIONS");
textcolor(DARKGRAY);

gotoxy(24,15); printf("Enter (1--6) for Stack Operations");
gotoxy(24,4); printf("(1) Push");
gotoxy(24,6); printf("(2) Pop");
gotoxy(24,8); printf("(3) Search");
gotoxy(24,10); printf("(4) Insert");
gotoxy(24,12); printf("(5) Replace");
gotoxy(24,14); printf("(6) Delete\n\n");
bar(0,y/2+4,x,y/2+6);
setcolor(MAGENTA);
setlinestyle(0,0,3);
line(3*x/4,y/12-7,3*x/4,y/2-7);
line(3*x/4+100,y/12-7,3*x/4+100,y/2-7);
for (i=0;i<7;i++)
{
line(3*x/4,y/2-i*33-7,3*x/4+100,y/2-i*33-7);
gotoxy(55,14-2*i);
if (i<6)
printf("® %d ¯",i);
}
press_esc();
}

void close(void)
{
int mx, my;
/* request auto detection */
int gd= DETECT, gm;
initgraph(&gd,&gm,"f:\\tc\\bgi");
mx = (getmaxx() / 2);
my = (getmaxy() / 2);

//SET baqckground color
setfillstyle(9, 1);
bar(0,0,getmaxx(),getmaxy());

//DRAW a bar, and make it look like a 3d bar
setfillstyle(1,7);
//bar(50,20,600,400);

//DRAW lines for the top and left side
setcolor(15);
line(50,20,600,20);
line(51,21,599,21);
line(50,20,50,400);
line(51,21,51,399);

//DRAW lines for the bottom and right side
setcolor(8);
line(600,20,600,400);
line(599,21,599,400);
line(50,400,600,400);
line(51,399,600,399);

//DRAW two 3D bars for the left and right side

setfillstyle(9,8);
bar(70,40,100,380);
bar(70,40,550,70);
bar(70,350,550,379);
//getch();
bar(545,40,575,380);

//PRINT 3D text CALENDAR
settextstyle(1, 0, 4);
settextjustify(1,1);
setcolor(LIGHTGREEN);
outtextxy(mx+2, my - 46, "Thank You!");
setcolor(LIGHTGREEN);
outtextxy(mx + 1, my - 45, "Thank You!");
setcolor(GREEN);
outtextxy(mx + 2, my - 44, "Thank You!");

//PRINT
settextstyle(2, 0, 5);
setcolor(WHITE);
outtextxy(mx + 1, my + 150, "Copyright www.forum.daneshjuha.org");

getch(); //PAUSE for a while
closegraph();
//initgraph(&gd,&gm,"e:\tc\bgi");


}

//Start
void start_screen()
{
int mx, my;
/* request auto detection */
int gd= DETECT, gm;
initgraph(&gd,&gm,"f:\\tc\\bgi");
mx = (getmaxx() / 2);
my = (getmaxy() / 2);

//SET baqckground color
setfillstyle(9, 1);
bar(0,0,getmaxx(),getmaxy());

//DRAW a bar, and make it look like a 3d bar
setfillstyle(1,7);
//bar(50,20,600,400);

//DRAW lines for the top and left side
setcolor(15);
line(50,20,600,20);
line(51,21,599,21);
line(50,20,50,400);
line(51,21,51,399);

//DRAW lines for the bottom and right side
setcolor(8);
line(600,20,600,400);
line(599,21,599,400);
line(50,400,600,400);
line(51,399,600,399);

//DRAW two 3D bars for the left and right side

setfillstyle(9,8);
bar(70,40,100,380);
bar(70,40,550,70);
bar(70,350,550,379);
//getch();
bar(545,40,575,380);

//PRINT 3D text CALENDAR 2002
settextstyle(1, 0, 4);
settextjustify(1,1);
setcolor(LIGHTGREEN);
outtextxy(mx+2, my - 150, "!...Wel Come...!");
setcolor(LIGHTGREEN);
outtextxy(mx + 1, my - 149, "!...Wel Come...!");
setcolor(GREEN);
outtextxy(mx + 2, my - 148, "!...Wel Come...!");

setcolor(GREEN);
outtextxy(mx + 2, my - 100, "Stack Operations");


//Print 3D Text
setcolor(WHITE);
outtextxy(mx, my-50, "BY");
setcolor(DARKGRAY);
outtextxy(mx, my + 5, "hossein azarpevand");
setcolor(DARKGRAY);
outtextxy(mx + 1, my + 6, "hossein azarpevand");
setcolor(LIGHTGRAY);
outtextxy(mx+1, my + 7, "hossein azarpevand");

//PRINT copyright notice
settextstyle(2, 0, 5);
setcolor(WHITE);
outtextxy(mx + 1, my + 150, "Copyright www.forum.daneshjuha.org");

getch(); //PAUSE for a while
closegraph();
initgraph(&gd,&gm,"e:\tc\bgi");
}

void press_esc()
{
settextstyle(2, 1, 5);
setcolor(RED);
outtextxy(600, 60,"..Press Esc to Exit..");

}

karma
10-25-2008, 10:26 PM
خیلی عالی بود

sunyboy
10-26-2008, 01:23 AM
این برنامه رو آقای karma درخواست کرده بودند امیدوارم بدردشات بخورد

فقط دقت کنید مسیر کامپایلری که من دادم مال دستگاه خودم بود!! شما در هر مسیری که کامپایلرتان نصب شده رو در ان قسمت قرار دهید!!!

موفق باشید




#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <graphics.h>
#include <math.h>
#include <bios.h>

void main()
{
int gd=DETECT,gm,no,rad=210;
struct time t;
float theta,x,y,x1,y1,theta1,theta2;
char des[40],ch;
initgraph(&gd,&gm,"d:\\borlandc\\bgi");
setcolor(14);
circle(320,240,180);
circle(320,240,15);
setcolor(BLACK);
circle(320,240,170);
circle(320,240,165);
circle(320,240,158);
circle(320,240,16);
setcolor(11);
for(theta=0.0,no=0;no<60;no++,theta+=.1047)
{
if(no%5==0)
{
x=320+158*cos(theta);
y=240+158*sin(theta);
}
else
{
x=320+165*cos(theta);
y=240+165*sin(theta);
}
x1=320+170*cos(theta);
y1=240+170*sin(theta);
line(x,y,x1,y1);
}
settextjustify(CENTER_TEXT,CENTER_TEXT);
setcolor(YELLOW);
for(no=1,theta=5.236;no<=12;no++,theta+=.524)
{
x=320+rad*cos(theta);
y=240+rad*sin(theta);
settextstyle(GOTHIC_FONT,HORIZ_DIR,5);
sprintf(des,"%d",no);
outtextxy(x,y,des);
}
gettime(&t);
theta1=(.0175*6*t.ti_min)-1.5708;
theta2=(.0175*30*(t.ti_hour%12+t.ti_min/60.0))-1.5708;

while(bioskey(1)==0)
{
gettime(&t);
theta=(.0175*6*t.ti_sec)-1.5708;
x=320+15*cos(theta);
y=240+15*sin(theta);
x1=320+150*cos(theta);
y1=240+150*sin(theta);
setcolor(11);
setlinestyle(SOLID_LINE,1,1);
line(x,y,x1,y1);
sound(7000);
delay(100);
nosound();
delay(900);
setcolor(BLACK);
line(x,y,x1,y1);
setlinestyle(SOLID_LINE,1,3);

x=320+15*cos(theta1);
y=240+15*sin(theta1);
x1=320+150*cos(theta1);
y1=240+150*sin(theta1);
line(x,y,x1,y1);

x=320+15*cos(theta2);
y=240+15*sin(theta2);
x1=320+100*cos(theta2);
y1=240+100*sin(theta2);
line(x,y,x1,y1);

theta1=(.0175*6*(t.ti_min+t.ti_sec/60.0))-1.5708;
x=320+15*cos(theta1);
y=240+15*sin(theta1);
x1=320+150*cos(theta1);
y1=240+150*sin(theta1);
setcolor(14);
line(x,y,x1,y1);
circle(320,240,15);

theta2=(.0175*30*(t.ti_hour%12+t.ti_min/60.0))-1.5708;
x=320+15*cos(theta2);
y=240+15*sin(theta2);
x1=320+100*cos(theta2);
y1=240+100*sin(theta2);
line(x,y,x1,y1);
}
getch();
closegraph();
}

sunyboy
10-26-2008, 02:01 AM
این در این برنامه هر عددی بین 1 تا 99 را وارد کنید معادل اسم عدد رو چاپ می کند مثلا اگر عدد 2 را وارد کنیم معادل اسمش یعنی towرا چاپ میکند این برنامه رو میتونید گسترش بدین..

موفق باشید



#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num,div,res,rem;
cout<<"enter and Digit 1 to 99 = ";
cin>>num;
if (num>=1 && num<=20)
{
if (num==1)
cout<<"one";
if (num==2)
cout<<"two";
if (num==3)
cout<<"";
if (num==4)
cout<<"four";
if (num==5)
cout<<"five";
if (num==6)
cout<<"six";
if (num==7)
cout<<"seven";
if (num==8)
cout<<"eight";
if (num==9)
cout<<"nine";
if (num==10)
cout<<"ten";
if (num==11)
cout<<"eleven";
if (num==12)
cout<<"twelve";
if (num==13)
cout<<"thirteen";
if (num==14)
cout<<"fourteen";
if (num==15)
cout<<"fifteen";
if (num==16)
cout<<"sixteen";
if (num==17)
cout<<"seventeen";
if (num==18)
cout<<"eighteen";
if (num==19)
cout<<"ninteen";
if (num==20)
cout<<"twenty";
}

if (num>=21 && num<=99)
{
rem=num%10;
res=num-rem;
div=res/10;
switch (div)
{
case 2:
cout<<"twenty"; break;
case 3:
cout<<"thirty";break;
case 4:
cout<<"fourty";break;
case 5:
cout<<"fifty";break;
case 6:
cout<<"sixty";break;
case 7:
cout<<"seventy";break;
case 8:
cout<<"eighty";break;
case 9:
cout<<"ninety";break;
}
switch (rem)
{
case 1:
cout<<"one";break;
case 2:
cout<<"two";break;
case 3:
cout<<"three";break;
case 4:
cout<<"four";break;
case 5:
cout<<"five";break;
case 6:
cout<<"six";break;
case 7:
cout<<"seven";break;
case 8:
cout<<"eight";break;
case 9:
cout<<"nine";break;
}


}
getch();
}

SaHaR-A
10-26-2008, 04:57 PM
سلام و خسته نباشید
من دانشجوی رشته ی کامپیوتر هستم و تقریبا در درسام موفق هستم بجز برنامه نویسی که خیلی برام مشکله حتی برنامه های ساده رو هم برام سخته حل کنم اگه می شه چند تا برنامه بهتون می دم اگه تونستید برام بنویسید خیلی ممنون میشم
یکی از برنامه ها اینست که یک عدد لاتین را خوانده و آن را به فارسی تبدیل کند
یعنی اگر 136 دادیم برایمان sado sio shesh بنویسد
و یکی از برنامه اینه که دو ماتریس 3*4و4*5را باهم ضرب کند
و برنامه ی اخری
10 جمله را خوانده تعدادحروف.ارقام و کلمات را تعیین کند
اگه به برنامه ها جواب دادید خیلی ممنون میشم

sunyboy
10-26-2008, 07:29 PM
برنامه ای که وقتی اعداد یه ماتریس به برنامه میدیم به ما بگه که این ماتریس هم ارزی هست یا نه و مشخص کنه ویژگی های بازتابی و تقارنی و تعدی رو...







#include <iostream>
#include <conio>
int main(){
int n;
bool r1,r2,r3;
cout<<"Enter Size of Matrix\n";
cin>>n;
//--------------
int **a=new int*[n];
for(int i=0;i<n;i++)
a[i]=new int[n];
//--------------
cout<<"Enter Your Matrix\n";
for(int i=0;i<n;i++){
for(int j=0;j<n;j++)
cin>>a[i][j];
}
cout<<"___________________________________\n\n";
//--------------
//Baztabi
int f1=0;
for(int i=0;i<n;i++){
if(a[i][i]==1)
f1++;
}
if(f1==n){
cout<<"Baztabi Ast\n\n";
cout<<"-----------------\n";
r1=true;
}
else{
cout<<"Baztabi Nist\n\n";
cout<<"-----------------\n";
r1=false;
}
//--------------
//Tagharoni
int f2=0;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(i<j){
if(a[i][j]==a[j][i])
f2++;
}
}
}
if(f2==(((n*n)-n)/2)) {
cout<<"Tagharoni Ast\n\n";
cout<<"-----------------\n";
r2=true;
}
else{
cout<<"Tagharoni Nist\n\n";
cout<<"-----------------\n";
r2=false;
}
//--------------
//Ta-addi
int f3=0;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
for(int k=0;k<n;k++){
if((a[i][j]==1 && a[j][k]==1))
{
if(a[i][k]!=1){
f3++;
break;
}
}
}}}
if(f3==0) {
cout<<"Taaddi Ast\n\n";
r3=true;
}
else{
cout<<"Taaddi Nist\n\n";
r3=false;
}
//--------------
cout<<"________________________________\n\n";
if(r1==true && r2==true && r3==true){
cout<<"Hamarzi Ast\n\n";
cout<<"-----------------\n";}
else{
cout<<"Hamarzi Nist\n\n";
cout<<"-----------------\n";
}
getch();
}

sunyboy
10-26-2008, 11:21 PM
سلام و خسته نباشید
من دانشجوی رشته ی کامپیوتر هستم و تقریبا در درسام موفق هستم بجز برنامه نویسی که خیلی برام مشکله حتی برنامه های ساده رو هم برام سخته حل کنم اگه می شه چند تا برنامه بهتون می دم اگه تونستید برام بنویسید خیلی ممنون میشم
یکی از برنامه ها اینست که یک عدد لاتین را خوانده و آن را به فارسی تبدیل کند
یعنی اگر 136 دادیم برایمان sado sio shesh بنویسد
و یکی از برنامه اینه که دو ماتریس 3*4و4*5را باهم ضرب کند
و برنامه ی اخری
10 جمله را خوانده تعدادحروف.ارقام و کلمات را تعیین کند
اگه به برنامه ها جواب دادید خیلی ممنون میشم

با سلام

برای اینکه در برنامه نویسی مهارت لازم رو داشته باشید و موفق باشید اول باید الگوریتم برنامه نویسی را خوب تقویت کنید و در ضمن سعی کنین هر خیلی زیاد تمرین یک برنامه نویس موفق در اول کار مبتدی بود وبا تمرینات زیاد و نوشتن انواع برنامه های کوچک و بزرگ و ساده و پیچیده شروع کرده است من بزودی اموزش برنامه نویسی را شروع خواهم کرد!!
شما اگر در سایت ما ماندگار شدین و فعالیت کردین میتونین استفاده کنین!!

من برنامه هایی که خواسه بودین رو آماده کردم امیدوارم همونایی باشه که شما خواسته بودین!! در ضمن برنامه شماره یکی که خواسته بودین رو می تونین از پست شماره (30 "برنامه 1 تا 99")همین تاپیک استفاده کنین فقط یکمی تغییر بدین تا بصورتی که میخواین عمل کنه!!
اگر بازم هر گونه سوال داشتین در خدمتم!!


با احترام

sunyboy
10-26-2008, 11:24 PM
برنامه ای که 10 جمله را خوانده تعداد حروف، ارقام و کلمات را تعیین کند :


#include <stdio.h>
#include <conio.h>
#include <iostream.h>

int words,alphabets,numbers;

void getcount(char s[])
{
int state=0;
char chars[]=" !()*+,./:;<=>?[\\]^`{}~";
for (int pos=0;s[pos];pos++)
{
if (((s[pos]>='A') && (s[pos]<='Z'))
|| ((s[pos]>='a') && (s[pos]<='z')))
{
state=1;
alphabets++;
}
else if ((s[pos]>='0') && (s[pos]<='9'))
{
state=1;
numbers++;
}
else
for (int chpos=0;chars[chpos];chpos++)
if (chars[chpos]==s[pos])
{
if (state)
words++;
state=0;
break;
}
}
if (state)
words++;
}

int main()
{
int i;
char s[500];
clrscr();
words=0;
alphabets=0;
numbers=0;
for (i=0;i<10;i++)
{
cout << "Please enter a text #" << (i+1) << " : " << endl;
gets(s);
getcount(s);
}
cout << endl << "Count of words = " << words << endl;
cout << endl << "Count of alphabet chars = " << alphabets << endl;
cout << endl << "Count of numeric chars = " << numbers << endl;
cout << endl << "Press any key to continue." << endl;
getch();
return 0;
}

sunyboy
10-26-2008, 11:26 PM
برنامه ای که دو ماتریس (3 در 4) و (4 در 5) را در هم ضرب کند




#include <stdio.h>
#include <conio.h>

void main()
{
int i,j,k;
char matrixA[3][4], matrixB[4][5], matrixC[3][5];
clrscr();
for (i=0;i<3;i++)
for (j=0;j<4;j++)
{
printf("A[%d,%d] = ", i+1, j+1);
scanf ("%d", &matrixA[i][j]);
}
for (i=0;i<4;i++)
for (j=0;j<5;j++)
{
printf("B[%d,%d] = ", i+1, j+1);
scanf ("%d", &matrixB[i][j]);
}
for (i=0;i<3;i++)
for (j=0;j<5;j++)
{
matrixC[i][j]=0;
for (k=0;k<4;k++)
matrixC[i][j]+= matrixA[i][k]*matrixB[k][j];
}
clrscr();
for (i=0;i<3;i++)
{
for (j=0;j<5;j++)
printf("%5d ", matrixC[i][j]);
printf("\n\n");
}
getch();
}

karma
10-27-2008, 12:27 AM
آقای مدیر ممنون به خاطر برنامه ساعت عقربه ای
اگه اومدی دانشکاه چند سوال راجع به اون برنامه ازتون دارم .
با تشکر

sunyboy
10-27-2008, 12:34 AM
در خدمتم

sunyboy
10-27-2008, 01:57 AM
برنامه ای که یک عدد لاتین را خوانده و آن را به فارسی تبدیل کند

دوست عزیز sosoجان بنده این برنامه شما رو هم نوشتم



#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>

void main()
{
long int n;
ldiv_t d;
int level=0;
int num,i;

char t1000[4][20]={"","hezar","milion","miliard"};
char t100[10][20]={"","yeksad","devist","sisad","chaharsad","pansad",
"sheshsad","haftsad","hashtsad","nohsad"};
char t10[10][20]={"dah","yazdah","davazdah","sizdah","chahardah","panzdah",
"shanzdah","defdah","hejdah","noozdah"};
char t20[10][20]={"","","bist","si","chehel","panjah",
"shast","haftad","hashtad","navad"};
char t1[10][20]={"","yek","do","seh","chahar","panj",
"shesh","haft","hasht","noh"};

char s[80],t[80],u[80];
clrscr();
printf ("Please enter a number : ");
scanf ("%ld", &n);
if (n==0)
strcpy(s,"Sefr");
else
{
strcpy(s,"");
do
{
d = ldiv(n,1000L);
num=(int) d.rem;
n=d.quot;
strcpy(t,t100[num / 100]);
i=num % 100;
if ((i >= 10) && (i <= 19))
{
if (t[0])
strcat(t," o ");
strcat(t,t10[i-10]);
}
else
{
if ((t[0]) && (i >= 20))
strcat(t," o ");
strcat(t,t20[i / 10]);
if (i % 10)
{
if (t[0])
strcat(t," o ");
strcat(t,t1[i % 10]);
}
}
if (t[0])
{
if (s[0])
strcpy(u," o ");
else
strcpy(u,"");
strcat(u,s);
strcpy(s,t1000[level]);
strcat(s,u);
strcat(t,s);
strcpy(s,t);
}
level++;
} while (n);
}
printf ("%s",s);
getch();
}

karma
10-31-2008, 10:31 PM
#include <iostream>
#include <conio>
struct stack
{
int value;
struct stack *top;
};
void insert(struct stack *,int);
int remove(stack *,bool*);
void print(stack *);
struct stack sample;
int main()
{
char ch;
bool flag=0;
int item,d;
while(1)
{
clrscr();
gotoxy(45,23);
cout<<"*** Writting By Karma ***";
gotoxy(1,1);
cout<<"\n\nWhat do you want to do?\n\n";
cout<<"1-insert\n2-remove\n3-Print\n4-Exit\n\n";
cout<<"What is your selection:";
cin>>ch;
switch(ch)
{
case'1':
clrscr();
cout<<"\n\nPlease neter a number to add:";
cin>>item;
insert(&sample,item);
break;
case'2':
d=remove(&sample,&flag);
if(flag==1)
{
clrscr();
cout<<"\n\nYour deleted number is:";
cout<<d;
getch();
}
break;
case'3':
print(&sample);
getch();
break;
case'4':
return 0;
}
}
getch();
return 0;
}
//***********************************************
void insert(struct stack *p,int item)
{
struct stack*temp;
temp=new struct stack;
temp->value=item;
if(p==0)
p=temp;
else
{
temp->top=p->top;
p->top=temp;
}
}
//***********************************************
int remove(stack *p,bool*flag)
{
int item;
struct stack*temp;
temp=p->top;
if(p==0||p->top==0)
{
clrscr();
cout<<"\nVoid deletion";
getch();
*flag=0;
}
else
{
temp=p->top;
item=temp->value;
p->top=temp->top;
*flag=1;
}
delete temp;
return item;
}
//***********************************************
void print(struct stack*p)
{
int i=0;
struct stack*temp;
temp=p;
while(temp!=0)
{
if(i!=0)
cout<<" <- "<<temp->value;
temp=temp->top;
i++;
}
}
//***********************************************

sunyboy
11-03-2008, 08:58 PM
دفرچه تلفن ساده




#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <iostream.h>
#include <string.h>





main()
{
menu:

int cm1;
char tn[81];
char view[100];
char add[100];
FILE *fptr;

clrscr();
cout << "Menu: " << "1.Create new phone book\n" << " 2.View or edit phone book\n" << " 3.Quit\n";
cin >> cm1;
switch (cm1)
{
case 1:
clrscr();
cout << "Enter name... Warning! Don't create files with same names.\n";
cin >> tn;
fptr = fopen(tn, "w");
fclose(fptr);
goto menu;
case 2:
goto submenu1;
case 3:
exit(0);
}
submenu1:
clrscr();
cout << "Submenu: 1.View\n 2.Add info.\n 3.Delete info.\n 4.Main menu\n";
cin >> cm1;
switch (cm1)
{
case 1:
goto viewmode;
case 2:
goto addmode;
case 3:
goto deletemode;
case 4:
goto menu;
}
viewmode:
clrscr();
cout << "Enter phone book name...\n";
cin >> tn;
clrscr();
if ((fptr = fopen(tn, "r")) == NULL)
{
printf("Can't open %s, enter any key to go to the submenu.", tn);
cin >> tn;
fclose(fptr);
goto submenu1;
}
while (fgets(view, 100, fptr) != NULL)
fputs(view, stdout);
fclose(fptr);
cout << "\n\nEnter any key to go back to submenu...\n";
getch();
goto submenu1;

addmode:
clrscr();
cout << "What file do you wish to add to?\n";
cin >> tn;
if ((fptr = fopen(tn, "a")) == NULL)
{
printf("Can't open %s, enter any key to go to the submenu.\n",tn);
cin >> tn;
fclose(fptr);
goto submenu1;
}
cout << "Enter the info. you would like to add..\n";
gets(add);
fputs(add, fptr);
fputs("\n", fptr);
fclose(fptr);
goto submenu1;

deletemode:
clrscr();
cout << "Refresh which phone book?\n";
cin >> tn;
if ((fptr = fopen(tn, "w")) == NULL)
{
printf("Can't open %s, enter any key to go to the submenu.\n",tn);
cin >> tn;
fclose(fptr);
goto submenu1;
}
cout << "Done...\n";
getch();
goto submenu1;

}

sunyboy
11-03-2008, 09:41 PM
ماشین حساب گرافیکی که جمع و ضرب و تفریق اعداد تا 128 رقم رو میتونه خیلی سریع حساب کنه ( ماشین حساب ویندوز تا 32 رقم اجازه میده ) .
کد این برنامه رو به صورت خیلی ساده و با استفاده از آرایه ها نوشتم. از تابع ضرب اون برای حساب کردن فاکتوریل اعداد بزرگ نیز میشه استفاده کرد. و برای قسمت گرافیکی آن به ناچار از Turbo C++ 3.0 استفاده کردم.








#include <graphics.h>
#include <conio.h>
#include <iostream.h>
#include <stdlib.h>
#include <dos.h>
#define ESC 0x1b
#define EXIT 120

void draw(void);
void getArray( int[],char& );
void printArray( int[] );
void reverseArray( int[] );
void plus(int[], int[], int[]);
void minus(int[], int[], int[]);
void multiple(int[], int[], int[] );
void initgraph();
void animate( char );
void wellcome(void);
void error(void);

int main(void)
{

char func='n';
int value1[128] ,
value2[128] ,
result[128] = {0};

initgraph();
wellcome();
draw();

getArray( value1, func );
reverseArray( value1 );

getArray( value2, func );
reverseArray( value2 );

switch( func )
{
case '+':
plus(value1, value2, result);
break;
case '-':
minus(value1, value2, result);
break;
case '*':
multiple(value1, value2, result);
break;
default: cout << "Oh sorry! You made a mistake.";
}

printArray ( result );

if(getch() == ESC )
{
cleardevice();
main();
}
closegraph();
return 0;
}
/*=================Draw===========*/
void draw (void)
{
int x = getmaxx();
int y = getmaxy();

settextstyle(2,HORIZ_DIR,4);
setfillstyle(SOLID_FILL, LIGHTBLUE);

bar(x / 2 - 210, 50, x / 2 + 210, 270);
setfillstyle(SOLID_FILL, WHITE);
bar(x / 2 - 200, 60, x / 2 + 200, 155);

setcolor(BLACK);
line(125,120,x / 2 + 190, 120);
line(125,125,x / 2 + 190, 125);

setfillstyle(SOLID_FILL, BLUE);


setcolor(BLUE);
int Y = 165;
for ( int i = 0; i < 3; i++)
{
int X = 220;
for ( int j = 0; j < 4; j++)
{
bar3d(X,Y,X + 25,Y + 25,3,1);
X += 35;
if ( j == 2 )
X += 15;
}
Y += 35;
}
bar3d(375,165,410,260,3,1);

setcolor(WHITE);
outtextxy(230,172,"1");
outtextxy(265,172,"2");
outtextxy(300,172,"3");
outtextxy(350,172,"+");
outtextxy(230,207,"4");
outtextxy(265,207,"5");
outtextxy(300,207,"6");
outtextxy(350,207,"-");
outtextxy(390,207,"=");
outtextxy(230,242,"7");
outtextxy(265,242,"8");
outtextxy(300,242,"9");
outtextxy(350,242,"x");

}
/*======= initgraph ===============*/
void initgraph()
{
int gdriver = DETECT, gmode, errorcode;

initgraph(&gdriver, &gmode, "C:\\tc\\bgi\\");
}
/*=====================getArray===============*/
void getArray( int value1[], char& func )
{
int xpos = 115, ypos = 65;
if( func != 'n' ) ypos += 3 * textheight("1");


for ( int i = 0; i<128; i++ )
value1[i] = -1;

int digit = 0;
char c;
char* cc;
while(digit < 128)
{
setcolor(BLUE);
c = getch();
animate(c);
if ( c == '+' )
{
func = '+';
outtextxy(125,65 + 2 * textheight("1"),"+");
return;
}
else if ( c == '-' )
{
func = '-';
outtextxy(125,65 + 2 * textheight("1"),"-");
return;
}
else if ( c == '*' )
{
func = '*';
outtextxy(125,65 + 2 * textheight("1"),"x");
return;
}
else if ( (int)c == 13 )
{
return;
}
else if ( c == ESC )
{
cleardevice();
main();
}
else if ( c == EXIT )
{
exit(0);
}
else
value1[digit++] = c - 48;

cc[0] = c;
cc[1] = '\0';
if( digit == 65 )
{
xpos = 115;
ypos += textheight("1");
}
xpos += textwidth("1");
outtextxy(xpos,ypos,cc);
}

return;
}
/*===================printArray==================== ===*/
void printArray( int value[])
{
int digit = 0, xpos = 115, ypos = 130;
char* cc;
cc[1] = '\0';
char c;

for ( digit = 0; digit < 128 && value[digit] == 0; digit++)
{

}

if ( digit == 127 )
outtextxy(115 + textwidth("1"),130,"0");

for(int count = 0 ; digit < 128; digit++,count++)
{
c = value[digit] + 48;
cc[0] = c;
xpos += textwidth("1");
if ( count == 65 )
{
ypos += textheight("1");
xpos = 121;
}
outtextxy(xpos,ypos,cc);
}
return;
}
/*===================plus========================== ===*/
void plus(int value1[], int value2[], int result[])
{

for ( int i = 127; i >= 0 && value1[i] >= 0; i-- )
result[i] += value1[i];

for (i = 127; i >= 0 && value2[i] >= 0; i-- )
result[i] += value2[i];



for ( i = 127; i >= 0; i-- )
{
if ( (result[1] / 10) + result[0] > 9 )
error();

if ( result[i] > 9 )
{
result[i-1] += result[i] / 10;
result[i] %= 10;
}
}
}
/*====================reverseArray===============*/
void reverseArray( int a[] )
{
int size = 127, temp;


for ( int i = 0; i < 128; i++ )
{
if ( *(a + i) == -1 )
{
size = i - 1;
break;
}
else
continue;
}

for ( i = 0; i <= size; i++ )
{
temp = *(a + size - i);
*(a + size - i) = *(a + 127 - i);
*(a + 127 - i ) = temp;
}
return;
}
/*========================minus==================== ===*/
void minus(int value1[], int value2[], int result[])
{
int big;


for ( int i = 0; i < 128; i++ )
{
if ( value2[i] > value1[i] )
{
big = 2;
break;
}
if ( value1[i] > value2[i] )
{
big = 1;
break;
}
}

if ( big == 1 )
{
for ( i = 127; i >= 0 && value1[i] >= 0; i-- )
result[i] += value1[i];

for ( i = 127; i >= 0 && value2[i] >= 0; i-- )
result[i] -= value2[i];
}

if ( big == 2 )
{
for ( i = 127; i >= 0 && value2[i] >= 0; i-- )
result[i] += value2[i];

for ( i = 127; i >= 0 && value1[i] >= 0; i-- )
result[i] -= value1[i];


outtextxy(115,130,"-");
}

for ( i = 127; i >= 0; i-- )
{
if ( (result[1] / 10) + result[0] > 9 )
error();

if ( result[i] < 0 )
{
result[i] += 10;
result[i-1]--;
}
}

return;
}
/*===========================multiple============== ===========*/
void multiple( int value1[], int value2[], int result[] )
{
int size1 = 127, size2 = 127;


for ( int i = 127; i >= 0; i-- )
{
if ( *(value1 + i) == -1 )
{
size1 = 127 - i;
break;
}
else
continue;
}


for (i = 127; i >= 0; i-- )
{
if ( *(value2 + i) == -1 )
{
size2 = 127 - i;
break;
}
else
continue;
}

if( size1 + size2 > 129 )
error();

/* cal */
for (int j = 0; j < size2; j++)
{
for( i = 0; i < size1; i++)
*(result + 127 - i - j) += *(value1 + 127 - i ) * *(value2 + 127 - j);
}


for ( i = 127; i >= 0; i-- )
{
if ( (result[1] / 10) + result[0] > 9 )
error();

if ( result[i] > 9 )
{
result[i-1] += result[i] / 10;
result[i] %= 10;
}
}
}
/*=========== animate============*/
void animate( char ch )
{
const int x[12] = {220,255,290,220,255,290,220,255,290,340,340,340};
const int y[12] = {165,165,165,200,200,200,235,235,235,165,200,235};
char* cc;
int k;

cc[0] = ch;
cc[1] = '\0';
if ( ch == '*' ) cc[0] = 'x';

switch(ch)
{
case '1' :
case '2' :
case '3' :
case '4' :
case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
k = int(ch) - 49;
break;
case '+' :
k = 9;
break;
case '-' :
k = 10;
break;
case '*' :
k = 11;
break;
default : return;
}

setfillstyle(SOLID_FILL,LIGHTBLUE);
bar(x[k], y[k] - 5, x[k] + 30, y[k] + 25);


setfillstyle(SOLID_FILL,BLUE);
bar(x[k] + 3, y[k] - 2, x[k] + 28, y[k] + 23);

delay(50);


setfillstyle(SOLID_FILL,LIGHTBLUE);
bar(x[k], y[k] - 5, x[k] + 30, y[k] + 25);


setfillstyle(SOLID_FILL,BLUE);
setcolor(BLUE);
bar3d(x[k], y[k], x[k] + 25, y[k] + 25,3,1);


setcolor(WHITE);
outtextxy(x[k] + 10, y[k] + 7,cc);
setcolor(BLUE);
}
/*======= well come ==========*/
void wellcome ( void )
{
cout<<"\n\n\n";
cout<<"\t\tWELCOME TO THE 128 DIGITS CACLULATER "<<endl;
cout<<"\n\n\n\n";
cout<<"FEW POINTS TO USE THIS CALCULATER. "<<endl<<endl;
cout<<"\n1. FIRST YOU NEED TO ENTER AN INTEGERS, THE OPERATOR THEN SECOND INTEGER. "<<endl;
cout<<"\n2. DO NOT ENTER CHARECTER INSTEAD OF INTEGER AS IT MAY CAUSE THE PROGRAM TO STOP RESPONDING."<<endl;
cout<<"\n3. TO CLEAR THE CALCULATOR AND USE AGAIN PRESS ESC"<<endl;
cout<<"\n4. TO EXIT THE PROGRAM PRESS X "<<endl<<endl;
cout<<"\n\n\n\n\n\t\t\twrite by: hossein azarpevand ";
sleep(7);
cleardevice();
}
/*========Error===================*/
void error( void )
{
setcolor(RED);
outtextxy(125,130,"Error.Result is out of range");
getch();

exit(1);
}

karma
11-09-2008, 01:19 AM
#include <conio.h>
#include <graphics.h>
#include <math.h>
#include <iostream.h>
#include <dos.h>
#include <stdio.h>
void mehvar();
void mos_1(int,int,int);
void mos_2(int,int,int);
int main()
{
char num[5];
int gd=DETECT,gm;
initgraph(&gd,&gm,"");
for(int i=1;i<5;i++)
for(int j=1;j<5;j++)
for(int k=1;k<5;k++)
{
mos_1(i,j,-k);
delay(1000);
nosound();
}
getch();
return 0;
}
//*******************************
void mehvar()
{
setcolor(15);
int x0,y0;
char num;
x0=getmaxx()/2;
y0=getmaxy()/2;
line(x0-300,y0+10,x0+300,y0+10);//X
line(x0,y0-200,x0,y0+200);//Y
}
//********************
void mos_1(int s,int Y,int X)
{
char num[5];
float deg,x0=320,y0=240;
clearviewport();
mehvar();
deg=-6.28;
while(deg<=6.28)
{
setcolor(14);
switch(s)
{
case 1:
outtextxy(deg*Y*40+x0,sin(deg*X)*40+y0,".");
sprintf(num,"%d",Y);
outtextxy(10,10,num);
outtextxy(20,10,"Y=Sin ");
sprintf(num,"%d",X);
outtextxy(60,10,num);
outtextxy(80,10,"X");
break;
case 2:
outtextxy(deg*Y*40+x0,cos(deg*X)*40+y0,".");
sprintf(num,"%d",Y);
outtextxy(10,10,num);
outtextxy(20,10,"Y=Cos ");
sprintf(num,"%d",X);
outtextxy(60,10,num);
outtextxy(80,10,"X");
break;
case 3:
outtextxy(deg*Y*40+x0,tan(deg*X)*40+y0,".");
sprintf(num,"%d",Y);
outtextxy(10,10,num);
outtextxy(20,10,"Y=sin ");
sprintf(num,"%d",X);
outtextxy(60,10,num);
outtextxy(80,10,"X");
break;
case 4:
outtextxy(deg*Y*40+x0,1/tan(deg*X)*40+y0,".");
sprintf(num,"%d",Y);
outtextxy(10,10,num);
outtextxy(20,10,"Y=Cot ");
sprintf(num,"%d",X);
outtextxy(60,10,num);
outtextxy(80,10,"X");
break;
}
deg+=0.01744;
}
}

sunyboy
11-16-2008, 03:01 AM
برنامه كوله پشتي 0-1 به روش برنامه سازي پويا:




#include <iostream.h>
#include <conio.h>
void main()
{
int i,j,n,l,p[10][20];
int weight,w[10];p[10];
cout<<"enter your namber of objects";
cin>>n;
for(i=0;i {
cout<<"enter w"<<"";
cin>>w[i];
cout<<"enter p";
cin>>p[i][0];
}
for(i=0;i p[i][0]=0;
for(j=0;j p[0][j]=0;
for(i=1;i for(j=1;j {
if(w[i]<=j)
{
if(p[i-1][j] < p[i][j]+p[i-1][j-w[i]])
p[i][j]=p[i-1][j-w[i]];
else
p[i][j]=p[i][j]+p[i-1][j-w[i]];
}
else
p[i][j]=p[i-1][j];
cout<< p[i][j];
}
getch();
}

sunyboy
11-16-2008, 03:14 AM
برنامه ی پازل به صورت برنامه نویسی back tracking یا همون(برنامه نویسی عقب گرد )



#include <stdio.h>
#include <stdlib.h>
#include <time.h>

// N should be >= 3
#define N 4

int board[N][N];

int showBoard() {

int i,val;

int row,col;
for ( row=0; row<N ; row++)
{
for ( col=0; col<N; col++)
{
if (board[row][col] == N*N){
printf(" *");
}
else {
printf("% 4d", board[row][col]);
}
}
printf("\n");
}
return 0;

}

int findKey(int val, int *v_f, int *v_c) {

int row,col;

*v_f = 0;
*v_c = 0;

if (val >= (N*N))
{
return 1;
}
for ( row=0; row<N ; row++)
{
for ( col=0; col<N; col++)
{
if (board[row][col] == val){
*v_f = row + 1;
*v_c = col + 1;
return 0;
}
}
}
return 1;

}

int findEmpty(int *v_f, int *v_c) {

int row,col;

*v_f = 0;
*v_c = 0;

for ( row=0; row<N ; row++)
{
for ( col=0; col<N; col++)
{
if (board[row][col] == N*N){
*v_f = row + 1;
*v_c = col + 1;
return 0;
}
}
}
return 1;

}

int move(int val) {
int row,col,filv,colv;
int i;

i=findKey(val, &row, &col);
i=findEmpty(&filv, &colv);

if ((row + 1 == filv && col == colv) ||
(row - 1 == filv && col == colv) ||
(row == filv && col + 1 == colv) ||
(row == filv && col - 1 == colv) )
{
board[row - 1][col - 1] = N*N;
board[filv - 1][colv - 1] = val;
return 0;
}
return 1;
}

int loadOrderedBoard() {

int row,col;

srand( (unsigned)time( NULL ) );

for ( row=0; row<N ; row++)
{
for ( col=0; col<N; col++)
{
board[row][col] = row * N + col;
}
}
return 0;

}

int gameOver() {

int row,col;
for ( row=0; row<N ; row++)
{
for ( col=0; col<N; col++)
{
if (board[row][col] != row * N + col + 1)
{
return 1;
}
}
}
return 0;

}

int checkParity() {

int i,j,paridad,dato;

paridad = 0;
for (i=0; i<(N*N) -1; i++)
{
dato = board[i/N][i%N];
if (dato != 16)
{
for (j=i+1; j<(N*N); j++)
{
if (board[j/N][j%N] < dato )
{
paridad++;
}
}
}
else {
paridad += (i/N) + 1;
}
}
return paridad % 2;

}

int fixParity()
{
int buf;
if (board[0][0] != (N*N) && board[0][1] != (N*N))
{
buf = board[0][0];
board[0][0] = board[0][1];
board[0][1] = buf;
}
else {
buf = board[1][0];
board[1][0] = board[1][1];
board[1][1] = buf;
}
}

int cheat()
{
int buf;

buf = board[N-1][N-2];
board[N-1][N-2] = board[N-1][N-3];
board[N-1][N-3] = buf;
return 0;
}

int loadBoard()
{
int i,j;
int base[N][N];

for (i=0; i<N*N; i++)
{
base[i/N][i%N] = 0;
}
srand((unsigned)time(NULL));
i=0;
while (i < N*N)
{
j = (int) ((float) (N*N) * rand() / (RAND_MAX + 1.0));
if (base[j/N][j%N] == 0)
{
base[j/N][j%N] = j+1;
board[i/N][i%N] = j+1;
i++;
}
}
}

int main()
{
int i, moves, option, play;

printf("1- Load random Board\n");
printf("2- Load ordered Board\n");
scanf("%d", &option);
switch (option)
{
case 1: loadBoard();
break;
case 2: loadOrderedBoard();
break;
default:
printf("I don't get that option!\n");
return 0;
break;
}
showBoard();
if (checkParity() != 0)
{
printf("ODD parity - No solution Board!\n");
printf("1- Fix Parity\n");
printf("2- Leave it\n");
scanf("%d", &option);
switch (option)
{
case 1: fixParity();
break;
case 2:
break;
default:
printf("I don't get that option!\n");
return 0;
break;
}
showBoard();
}
moves = 0;
play = 0;
do
{
printf("1 - %d to move\n", N*N-1);
printf("0 to exit\n");
printf("%d to cheat\n", N*N);
printf("Option: ");
scanf("%d", &play);
if (play == N*N)
{
cheat();
}
else if (move(play) == 0)
{
moves ++;
};
showBoard();
if (gameOver() == 0)
{
printf("GAME COMPLETED IN %03d MOVES!\n", moves);
play = 0;
}
printf("\n");
}while (play != 0);
}




توضیح: برنامه پازل یه ماتریس مثلا 4*4 هستش که حاوی اعداد 1 تا 15 هست و یک خونه ی باقیمانده اون خالیه .این اعداد 1 تا 15 به صورت بههم ریخته توی پازل قرار دارند و برنامه باید به کمک اون خونه ی خالی این اعداد رو به صورت پشت سر هم مرتب میکنه! و ضمنا برنامه این کار رو باید با استفاده از الگوریتم عقب گرد (back tracking ) انجام میده.

karma
11-25-2008, 12:03 AM
این برنامه به این صورته که یه چاقو در دست سر باز اولی و اون نفر بعدی رو می کشه و چاقو را به نفر زنده ی بعدی منتقل می کنه و این کار تا جایی ادامه پیدا میکنه که فقط یک سرباز زنده میمونه.(صف سربازان را به صورت حلقوی تصور کنید.)

#include<iostream>
#include<conio>
struct node
{
int data;
node*next;
};
void print(node*a,int n)
{
int i;
cout<<"\n";
for(i=1;i<=n;i++)
{
cout<<a->data<<" ";
a=a->next;
}
};
int main()
{
node*a,*first;
int i,j,n;
cout<<"Please enter number of soldiers :";
cin>>n;
for(i=1;i<=n;i++)
{
node*temp=new node;
temp->data=i;
if(i==1)
{
a=temp;
first=a;
}
else
{
a->next=temp;
a=temp;
}
temp->next=first;
}
a=first;
print(a,n);
while(n>1)
{
node*temp=new node;
temp=a->next;
a->next=temp->next;
delete temp;
a=a->next;
n--;
print(a,n);
}
cout<<"\n\nAll soldiers killed except : "<<a->data;
getch();
}
البته برای پیاده سازی اون از لیست پیوندی حلقوی استفاده کرده ام.

sunyboy
11-25-2008, 01:32 AM
برنامه ای که بکمک آرایه دو عدد 30 رقمی را با هم جمع و ضرب و تفریق میکند:



#include<iostream.h>
#include<stdlib.h>
#include<conio.h>
void print(char *);
void main()
{
char n1[31]* n2[31]* n3[32];
int i* carry = 0* sum;
clrscr();
cout << "Enter Number 1 (30 Digits): "; cin >> n1;
cout << "Enter Number 2 (30 Digits): "; cin >> n2;
for (i = 29; i >= 0; i --)
{
sum = n1[i] + n2[i] - 96 + carry;
if (sum > 9)
{
sum -= 10;
carry = 1;
}
else carry = 0;
n3[i+1] = sum + 48;
}
n3[0] = carry;
cout << "Sum: ";
print(n3);
getch();
}
void print(char n[31])
{
int i;
for (i=0; i<31; i++)
{
if (i != 0)
cout << n[i];
else if (n[i]==49)
cout << n[i];
}
}

sunyboy
11-25-2008, 01:54 AM
محاسبه ی 1 روی !n تا 60 رقم اعشار (http://www.storewith.com/filedownload.aspx?code=bfbea247aa572a434ca86aaa23a 5d2910b70)



#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
main()
{
int q[61],a[61],i,n,s;

printf("\n N ro vared kon ta 1/N! ro hesab konam: ");
scanf("%d",&s);
if(s==1)
{

printf("\n1/1!=1");
getch();
exit (0);
}
for(i=0;i<=60;i++)
{
a[i]=0;
q[i]=0;
}
for(n=2;n<=s;n++)
for(i=0;i<=60;i++)
{
if(n==2 && i==0)
a[0]=1;
q[i]=a[i]/n;
if(q[i]==0)
a[i+1]=a[i]*10+a[i+1];
else
a[i+1]=(a[i]%n)*10+a[i+1];
a[i]=q[i];
}

printf("\n 1/%d!= 0.",s);
for(i=1;i<=60;i++)
printf("%d",a[i]);
getch();
return 0;
}

sunyboy
11-25-2008, 01:57 AM
برنامه يک بر روی e تا ۵۰ اقم اعشار (http://www.storewith.com/filedownload.aspx?code=ae41a0f5a1f78a49a3a86fdab04 893c555e1)




#include<stdio.h>
#include<conio.h>
void main()
{
long int n;
int i,su[51],sm[51],sum[51],x,y,k,w,q[51],a[51];
clrscr();
for(i=0;i<=50;i++)
{
su[i]=0;
sm[i]=0;
a[i]=0;
q[i]=0;
sum[i]=0;
}
for(n=2;n<=1000000;n++)
{
if(n==2)
a[0]=1;
for(i=0;i<=50;i++)
{
q[i]=a[i]/n;
if(q[i]==0)
a[i+1]+=a[i]*10;
else
a[i+1]+=(a[i]%n)*10;
a[i]=q[i];
}
for(i=50;i>=0;i--)
{
if(n%2==0)
{
su[i]+=a[i];
x=su[i]%10;
y=su[i]/10;
if(y!=0)
{
su[i]=x;
su[i-1]+=y;
}
}
else if(n%2!=0)
{
sm[i]+=a[i];
w=sm[i]%10;
k=sm[i]/10;
if(k!=0)
{
sm[i]=w;
sm[i-1]+=k;
}
}
}
}
for(i=50;i>=0;i--)
{
if(su[i]>=sm[i])
sum[i]=su[i]-sm[i];
else if(su[i]<sm[i])
{
sum[i]=10+su[i]-sm[i];
su[i-1]=su[i-1]-1;
}
}
printf("0.");
for(i=1;i<=50;i++)
printf("%d",sum[i]);
getch();
}

sunyboy
11-25-2008, 01:59 AM
اين برنامه زيرمجموعه های يک مجموعه را به شما نشان می دهد. روش کارش هم اينجوريه که اول بايد تعداد اعضای مجموعه را مشخص کنيد .
بعدش هم اعضای مجموعه رو يکی يکی وارد کنيد .
بعد از زدن اينتر زير مجموعه ها مشخص می شوند .



#include <stdio.h>
#include <conio.h>
#include<math.h>
int main()
{
int i,j,m,n;
clrscr();
printf("enter number : ");
scanf("%d",&n);
char a[100];
for(i=0;i<n;i++)
{
printf("x%d=",i+1);
scanf("%d",&a[i]);
}
for(j=0;j<pow(2,n);j++)
{
m=j;
printf("{");
for(i=0;i<=j;i++)
{
if(m%2==1)
{
printf("%d",a[i]);
printf(",");
m=(m-1)/2;
}
else m=m/2;
}
printf("}\n");
}
getch();
return 0;
}

sunyboy
11-25-2008, 02:03 AM
پروژه LINEEDITOR (http://pro_com85.persianblog.ir/post/6)

با این LINEEDITOR می تونید کارهایی مانند ویرایش کلمات حذف insert و یا هر کاری که مربوط به ویرایش است انجام بدید.این برنامه فقط در محیط tc قابل اجراست



#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#define LEN 10
#define SCAPE 27
#define RIGHT 77
#define LEFT 75
#define BACKSPACE 8
#define DELETE 83
#define END 79
#define HOME 71
#define INSERT 82
#define ISCONTROL 0
#define CtrL 12
#define CtrR 18
#define CtrY 25
#define CtrO 15
#define CtrS 19
#define TAB 9
//***********************************************
class LineEditor{
private:
int X,Y,Index,IsInsert,Numchar;
char ch,A[1000],S[12];
void Updatescreen(void){
int i,savepos=wherex()-X;
Peykan();
gotoxy(X,Y);
for(i=Index-savepos;i<Index-savepos+LEN;i++)
if(Numchar>i)
cprintf("%c",A[i]);
else
cprintf(" ");
gotoxy(X+savepos,Y);
}
/************************************************/
void Home (void){
Index=0;
gotoxy(X,Y);
}
/************************************************/
void End (void){
Index=Numchar-1;
if(Numchar<LEN-1){
gotoxy(X+Numchar-1,Y);
}
else{
gotoxy(X+LEN-1,Y);
}
}
/************************************************/
int Left (void){
if(Index==0)
return 0;
Index--;
if(wherex()>X)
gotoxy(wherex()-1,Y);
return 1;
}
/***********************************************/
int Right(void){
if(Index>Numchar-2)
return 0;
Index++;
int k=wherex();
if(k<X+LEN-1)
gotoxy(k+1,Y);
return 1;
}
/************************************************/
void Delete (void){
if(Index<Numchar-1){
for(int i=Index;i<Numchar;i++)
A[i]=A[i+1];
Numchar--;
}
}
/************************************************/
void Insert(char ch){
for(int i=Numchar-1;i>=Index;i--)
A[i+1]=A[i];
A[Index]=ch;
Numchar++;
Right();
}
/************************************************/
void Backspace(void){
if (Left())
Delete();
}
/************************************************/
void Overwrite(char ch){
if(Index==Numchar-1)
Insert(ch);
else{
A[Index]=ch;
Right();
}
}
/************************************************/
void clearleft(void){
int i,savepos=wherex()-X;
for(i=savepos;i>=0;i++)
Backspace();
gotoxy(X,Y);
}
/***********************************************/
void clearright(void){
Index++;
int c=Numchar-Index,i;
for(i=0;i<=c;i++)
Delete();
Index--;
}
/************************************************/
void clear(void){
clearright();
clearleft();
if(Numchar!=1)
Delete();
}
/************************************************/
void save(char S[]){
FILE *fp;
if ((fp=fopen(S,"wb"))==NULL){
gotoxy(X-30,Y+3);
printf("\ncannot open fill...");
getch();
exit(1);
}
fwrite(&A,2*strlen(A),1,fp);
gotoxy(X,Y);
clear();
fclose(fp);
open(S);
}
/************************************************/
void open (char S[]){
FILE *fp;
if ((fp=fopen(S,"rb"))==NULL){
gotoxy(X-30,Y+3);
gotoxy(X,Y);
}
fread(A,sizeof(A),1,fp);
Numchar=strlen(A)+1;
End();
fclose(fp);
}
//**********************************************
void Peykan (void){
int b=wherex();
int a=X+LEN-wherex();
if(Index==0){
gotoxy(X-1,Y);
cprintf(" ");
gotoxy(X,Y);
}
if(Numchar-Index-1>a){
gotoxy(X+LEN,Y);
cprintf("%c",16);
gotoxy(b,Y);
}
else{
gotoxy(X+LEN,Y);
cprintf(" ");
gotoxy(b,Y);
}
if(Index>LEN-1){
gotoxy(X-1,Y);
cprintf("%c",17);
gotoxy(b,Y);
}
if(wherex()-X<Index){
gotoxy(X-1,Y);
cprintf("%c",17);
gotoxy(b,Y);
}
}
//***********************************************
public:
LineEditor(int x,int y,char *s){
X=x;
Y=y;
Numchar=1;
IsInsert=0;
Index=0;
A[Numchar-1]='\0';
strcpy(S,s);
}
//***********************************************
void DetectKeyGo(void){
End();
Updatescreen();
while((ch=getch())!=SCAPE){
if (ch=='\r')
continue;
if((ch==ISCONTROL) || (ch==BACKSPACE) || (ch==CtrL) || (ch==CtrR) || (ch==CtrY) || (ch==CtrS) || (ch==CtrO) || (ch==TAB)){
if(ch==ISCONTROL)
ch=getch();
switch(ch){
case TAB: End();
if(Y<29) gotoxy(X,Y+5);
else gotoxy(X,Y-10);
return;
case END:End(); break;
case LEFT:Left(); break;
case HOME:Home(); break;
case CtrY:clear(); break;
case CtrS:save(S); break;
case CtrO:open(S); break;
case RIGHT:Right(); break;
case DELETE:Delete(); break;
case CtrL:clearleft(); break;
case CtrR:clearright(); break;
case BACKSPACE:Backspace(); break;
case INSERT:IsInsert++;
}}
else if (IsInsert%2==0)
Insert(ch);
else
Overwrite(ch);
Updatescreen();
} exit(0);
}
//************************************************
void Drawline (void){
textbackground(1);
textcolor(4);
gotoxy(X-1,Y);
for(int i=1;i<=LEN+2;i++)
cprintf(" ");
gotoxy(X,Y);
}
};
//***********************************************
void MYNAME(void){
textcolor(7);
gotoxy(26,5);
printf(" << In The Name Of God >>");
gotoxy(25,10);
printf(" << mohammad hadi moghaddami >>");
}
//***********************************************
int main(){
LineEditor L1(33,20,"LineE1.txt"),L2(33,25,"LineE2.txt"),L3(33,30,"LineE3.txt");
textbackground(0);
clrscr();
MYNAME();
L3.Drawline();
L2.Drawline();
L1.Drawline();
while(1){
L1.DetectKeyGo();
L2.DetectKeyGo();
L3.DetectKeyGo();
}
return 0;
}

sunyboy
02-05-2009, 12:48 PM
اين برنامه بسيار ساده است فقط در كامپايلر هاي تحت ويندوز مثل Microsoft Visual C قابل اجراست!!



#include <iostream>
#include <windows.h>
#include <cstdlib>
using namespace std;
void Hax(int*address)
{
short int random=NULL;
DWORD proc_id;
random = rand();


HWND hWnd = FindWindow(NULL,"MEMORY HAX");

GetWindowThreadProcessId(hWnd,&proc_id);


HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS,false,proc_id);

WriteProcessMemory(hProcess,(LPVOID)address,&random,1,NULL);
}
int main()
{
system("Title MEMORY HAX");
int x = 8;
while(x=x){cout << &x << " \\ " << x << endl;Sleep(500);Hax(&x);}
return 0;
}

pnugirl
02-05-2009, 01:12 PM
اولا كه اقاي مدير اموزش برنامه نويسي به زبان ++c را شروع كنيد و ضمن اينكه يه كتاب خوب معرفي كنيد كه بشه با خوندنش توي اين زبان يه برنامه نويس حرفه اي شد. مقسي

X2008
02-05-2009, 01:48 PM
اقای مدیر پیشنهاد میکنم کتابهایی که استاد حسین زاده دادند رو توی سایت قرار بدید تا بقیه دوستان هم استفاده کنند
به نظر من کتابهای خوبیند با اینکه به زبان انگلیسی هستند. ولی به خوندنش می ارزه.
با تشکر.

sunyboy
02-05-2009, 08:08 PM
اولا كه اقاي مدير اموزش برنامه نويسي به زبان ++c را شروع كنيد و ضمن اينكه يه كتاب خوب معرفي كنيد كه بشه با خوندنش توي اين زبان يه برنامه نويس حرفه اي شد. مقسي

آموزش لازم نيست هر كس مشكلي يا سوالي داشت مطرح كنه تا هر كس در حد توانش كمكش كنه!!
كتاب هم آموزش مهندس جعفرنژاد قمي خيلي خوبه

sunyboy
02-05-2009, 08:11 PM
اقای مدیر پیشنهاد میکنم کتابهایی که استاد حسین زاده دادند رو توی سایت قرار بدید تا بقیه دوستان هم استفاده کنند
به نظر من کتابهای خوبیند با اینکه به زبان انگلیسی هستند. ولی به خوندنش می ارزه.
با تشکر.

يكي از كتابهاي استاد رو قرار دادم توي همين تالار برنامه نويسي هست!! ولي بچه ها استقبال نكردند!! تازه ما ميخوايم اعتراض كنيم به مثلا نحوه امتحانات!! بنظر من هر بلايي سر دانشجويان پيام نوري بيارن بازم كمه!! چون خودمان خواهانيم!! دلايل زيادي داره كه همه ميدونن براي همين بنده تا اينجا بسنده ميكنم!!



با احترام

X2008
02-06-2009, 02:58 PM
يكي از كتابهاي استاد رو قرار دادم توي همين تالار برنامه نويسي هست!! ولي بچه ها استقبال نكردند!! تازه ما ميخوايم اعتراض كنيم به مثلا نحوه امتحانات!! بنظر من هر بلايي سر دانشجويان پيام نوري بيارن بازم كمه!! چون خودمان خواهانيم!! دلايل زيادي داره كه همه ميدونن براي همين بنده تا اينجا بسنده ميكنم!!



با احترام

خوب بله ولی ما خودمون باید برای هم دیگه انگیزه ایجاد کنیم .
استقبال هر چقدر هم که کم باشه حداقل برای اون چند نفری که میخواند و واقعا هم تلاش میکنند بگذارید. همیشه هم اینطور نیست که طرف اکثریت رو بگیریم.
انشا الله طرز درس خوندن تو پیام نور زودتر دستمون بیاد تا بیشتر از این خراب کاری نکردیم.
موفق باشید
با احترام

sunyboy
02-06-2009, 06:11 PM
خوب بله ولی ما خودمون باید برای هم دیگه انگیزه ایجاد کنیم .
استقبال هر چقدر هم که کم باشه حداقل برای اون چند نفری که میخواند و واقعا هم تلاش میکنند بگذارید. همیشه هم اینطور نیست که طرف اکثریت رو بگیریم.
انشا الله طرز درس خوندن تو پیام نور زودتر دستمون بیاد تا بیشتر از این خراب کاری نکردیم.
موفق باشید
با احترام

براي بنده همون تعداد اندك مهمه!! :36:

mahya1364
06-10-2009, 10:29 AM
سلام.خوبی؟میدونم الان وقت خوبی نیست و تو امتحاناست اما اگه ممکنه یه کمک ازتون می خواستم که خیلی ممنون میشم اگه سوالمو جواب بدید.دوتا برنامه c++ اگه ممکنه کد یکیشو میخواستم.هر کدوم راحتتره براتون .بازم ممنون.۱- برنامه ای بنویسید که نام روز اول سال را دریافت و تقویم ان سال را به شکل مناسب ماه به ماه یا فصل به فصل یا هر شکلی که بهتر می دانید نمایش دهد.۲- برنامه ای بنویسید که یک فایل متنی را خوانده و معین کند در این فایل چه کلماتی وجود دارد و هر کلمه چند بار و در چه سطرهایی تکرار شده است.( شماره سطرها )

sunyboy
06-10-2009, 10:59 AM
برنامه ای که رشته ای را در یک فایل جستجو میکند و تکرارهای رشته در فایل را در خروجی چاپ میکند

دوست عزیز این برنامه رو با کمی تغییر میتونید استفاده کنید


#include<iostream.h>
#include<fstream.h>
#include<string.h>
int main(void)
{
char filename [20], str [20] , searchstr [20];
int cont=0;
cout << "Enter FileName :";
cin>>filename;
cout<< "Enter string : ";
cin>> searchstr ;
ifstream in (filename);
if(!in)
{
cout<<"Cannat Open Input File.\n";
return 1;
}
while (!in.eof())
{
in>>str;
if(!strcmp(str,searchstr))
count++;
}
cout<<"found "<<cout;
cout<<"number of times.\n";
in.close();
retun 0;
}



موفق باشید



با احترام

sunyboy
06-23-2009, 10:54 AM
این برنامه ساده کد باینری رو از ورودی دریافت کرده و به حالت نوشته نشان میدهد!



#include <stdio.h>
#include <math.h>
int main(void) {
int dec=0, flag=0.0;
int bin, bit;
double exp=0.0;
printf("Enter a binary number : ");
scanf("%d", &bin);
while(bin) {
bit=bin%10;
if(bit!=0 && bit!=1) {
flag=1;
}
bin=bin/10;
dec=dec+bit*pow(2, exp);
exp++;
}
if(flag) {printf("\n+++ Not a binary number !!!\n");}
else {printf("\n+++ Number in decimal : %d\n", dec);}
return 0;
}

sunyboy
06-23-2009, 11:14 AM
این برنامه ساده دو عدد ورودی را گرفته و عمل x AND Y را انجام داده و نتیجه رو چاپ میکند!



#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;
}

sunyboy
06-27-2009, 02:37 PM
برنامه رسم دایره برسنهام بزبان ++c







#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();
}

sunyboy
06-27-2009, 02:39 PM
برنامه رسم خط DDA بزبان ++c



#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;
}

HeshaM
06-29-2009, 08:12 PM
من یک برنامه می خواستم که طبق منو که داره
1-مشخصات دانشجو رو وارد کنه ( از قبیل نام و نام خانوادگی و سال تولد و محل تولد و معدل )
2-و هر کدوم که معدلش زیر 12 هست رو نشون بده
3-دانشجویان مربوط به یک شهر رو نشون بده
4-با سرچ کردن نام و نام خانوادگی مشخصات اون نمایش داده بشه
5-خروج
***********************
هر چقدر تونستین برام بنویسین طوری که من بعدش توش تغییرات ایجاد کنم
بشدت ممنون

sunyboy
08-10-2009, 01:36 AM
اطلاعات عمومی دانشجو

خصوصیات برنامه:
1)وارد کردن نمره به تعداد دلخواه
2)بازه نمرات بین 0 تا 100
3)مشخص کردن وضعیت نمرات
4)گرفتن میانگین
5)مشخص کردن تعداد افراد قبول و مردود شده




#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;
}

sunyboy
08-10-2009, 01:39 AM
اوور لودینگ اپراتورها در کلاس در c++



#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();
}

sunyboy
08-10-2009, 01:42 AM
دفتر تلفن ساده با کلاس ها





#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

sunyboy
08-10-2009, 01:43 AM
مشخصات دانشجویان با امکان ورود اطلاعات حذف اطلاعات و جستجو



#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);
}
}
}

sunyboy
08-10-2009, 01:44 AM
کتابخانه با امکان ورود - ویرایش- حذف -به امانت گرفتن و پس دادن کتاب



#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);
}

fahime
08-17-2009, 11:28 AM
اگر امکانش هست برنامه حذف وجستجودر درختb را هم در سایت قرار دهید

0925
01-02-2010, 03:16 PM
برنامه صف و پشته با آرایه و لیست پیوندی

اكسيژن
03-15-2010, 12:09 AM
سلام يك پروژه c++دارم:
يك آدمك بسازيد كه با فشار دادن هر دكمه از صفحه كليد يك كاري انجام بده! مثلا با زدن كليدa بپره هوا..:297:

اكسيژن
03-26-2010, 10:17 PM
سلام
تو را به خدا گر وقت داريد كمك نماييد
پروژه دارم
يك برنامه بنويسيد كه يك آدمك باشه بعد با زدن هر كليد يك كاري انجام بده (مثلا با زدن كليد q
بپره) تو رو خدا كمك كنيد:79:

ali929
05-05-2010, 03:39 PM
بابت برنامه ها بسیار سپاس گذارم.

cfzbadboy
05-27-2010, 09:49 PM
سلام من در مورد اینکه یک برنامه با ++c بنویسم که حروف روکوچک بگیرد و بزرگ چاپ کند و اینکار تا وقتی ادامه داشته باشد که علامت ! رو وارد کنیم ....مشکل دارم میشه help کنید.

farnaz h
07-07-2010, 04:28 PM
سلام من یه برنامه ادیتور متن به زبان سی تحت داس میخوام نمیخوام خیلی پیشرفته باشه ساده باشه کافبه فقط تورو خدا کمکم کنید خیلی عجله دارم:251:

آرم
04-25-2012, 10:16 AM
سلام پروژه اي كه قبلا در خواست كرده بودم اگر مي شود برايم بفرستيد .

mahtabr
05-30-2012, 05:17 PM
#include <iostream>
#include <conio>
#include <fstream>
#include <algorithm>
#include <stdio>
#include <stdlib>
# define esc 27
#define enter 13
#define up 72
#define down 80
#define tab 9
class library
{
public:
struct book
{
char name[20];
char writer[20];
char date[15];
char publisher[20];
char subject[20];
int id,price;
}book1,booktemp;
int menu();
char addmenu(int *,char *);
void add();
void searchmenu(int *,char *);
void search();
void show(int*,char*,char *);
void deletmenu(char *);
void delet();
}book;
//***********************main*********************** ****************************
int main()
{
while(1)
{
window(1,1,80,25);
textbackground(0);
textcolor(15);
clrscr();
gotoxy(29,3);
cprintf("WELCOM TO MY LIBRARY");
gotoxy(55,23);
cprintf("*** SPRING OF 1387 **");
int select=book.menu();
switch(select)
{
case 1:book.add();break;
case 2:book.search();break;
case 3:book.delet();
case 4:
cout<<"\a";
window(10,5,70,20);
textbackground(1);
textcolor(15);
clrscr();
gotoxy(15,7);
cprintf("ARE YOU SURE (y/n)?");
char ex=getch();
if(ex==13||ex==121||ex==89)
return 0;
}
}
return 0;
}
//******************************functions*********** ****************************
int library::menu()
{
char item[4][20]={
"1->Insert","2->Search","3->Delet","4->Exit"},key;
int i=0,j=0;
window(10,5,70,20);
textbackground(3);
clrscr();
window(1,1,25,80);
while(1)
{
for(i=0;i<4;i++)
{
textbackground(3);
textcolor(14);
if(i==j)
{
textbackground(1);
textcolor(15);
}
gotoxy(2,2+(2*i));
cprintf("%s",item[i]);
}
gotoxy(2,2+(2*j));
key=getch();
switch(key)
{
case 49:j=0;break;
case 50:j=1;break;
case 51:j=2;break;
case 52:j=3;break;
case up:if(j==0)j=3;else j--;break;
case down:if(j==3)j=0;else j++;break;
case tab:if(j==3)j=0;else j++;break;
case enter:break;
case esc:return 4;
}
if(key==13)break;
}
return j+1;
}
//*****************************************
char library::addmenu(int *j,char *key)
{
char add[7][20]={
"Name :","Writer :","Date publisher :","Price :","publisher :","Subject :","Code:"};
int i,flag=0;
window(21,5,50,20);
textbackground(1);
clrscr();
while(1)
{
for(i=0;i<7;i++)
{
textbackground(1);
textcolor(14);
if(i==*j)
{
textbackground(3);
textcolor(15);
}
gotoxy(2,2+(2*i));
cprintf("%s",add[i]);
}
gotoxy(2,2+(2*(*j)));
*key=getch();
switch(*key)
{
case up:if(*j==0)*j=6;else (*j)--;break;
case down:if(*j==6)*j=0;else (*j)++;break;
case tab:if(*j==6)*j=0;else (*j)++;break;
case enter:break;
case esc:break;
}
if(*key==13||*key==27)break;
}
}
//************************************************** **
void library::add()
{
char add[7][20]={
"Name :","Writer :","Date publisher :","Price :","publisher :","Subject :","Code:"},key;
int j=0;
char ch=addmenu(&j,&key);
ofstream file1("C:\\library.dat",ios::app);
if(!file1) cout<<"\ncan not open file";
if(ch==13)
{
gotoxy(2,2+(2*j));textbackground(1);textcolor(14); cprintf("%s",add[j]);
gotoxy(2,2);textbackground(3);textcolor(15);cprint f("%s",add[0]);
gotoxy(8,2);cin.get(book1.name,20);cin.get();
gotoxy(10,4);cin.get(book1.writer,20);cin.get();
gotoxy(18,6);cin.get(book1.date,20);cin.get();
gotoxy(9,8);cin>>book1.price;cin.get();
gotoxy(13,10);cin.get(book1.publisher,20);cin.get( );
gotoxy(11,12);cin.get(book1.subject,20);cin.get();
gotoxy(7,14);cin>>book1.id;cin.get();
file1.write((char*)&book1,sizeof(struct book));
file1.close();
}
}
//************************************************** ******
void library::searchmenu(int*j,char*key)
{
char add[3][20]={"Name :","subject :","Code:"};
int i,flag=0;
window(21,7,50,15);
textbackground(1);
clrscr();
while(1)
{
for(i=0;i<3;i++)
{
textbackground(1);
textcolor(14);
if(i==*j)
{
textbackground(3);
textcolor(15);
}
gotoxy(2,2+(2*i));
cprintf("%s",add[i]);
}
gotoxy(2,2+(2*(*j)));
*key=getch();
switch(*key)
{
case up:if(*j==0)*j=2;else (*j)--;break;
case down:if(*j==2)*j=0;else (*j)++;break;
case tab:if(*j==2)*j=0;else (*j)++;break;
case enter:break;
case esc:break;
}
if(*key==13||*key==27)break;
}
}
//************************************************** ***********
void library::search ()
{
char add[3][20]={"Name :","subject :","Code:"},ch,n[20];
int i,j,cod;
searchmenu(&j,&ch);
if(ch!=27)
{
switch(j)
{
case 0:gotoxy(8,2);cin.get(n,20);cin.get();i=1;break;
case 1:gotoxy(11,4);cin.get(n,20);cin.get();i=2;break;
case 2:gotoxy(7,6);cin.get(n,20);cin.get();i=3;break;
}
}
int x=atol(n);
show(&x,n,&ch);
}
//************************************************** ***********
void library::show(int *x,char*n,char *ch)
{
char item[7][20]={
"Name :",
"Writer :",
"Date publisher :",
"Price :",
"publisher :",
"Subject :",
"Code:"
};
if(*ch!=27)
{
ifstream file1("C:\\library.dat",ios::out);
if(!file1) cout<<"\ncan not open file";
int j=0;
if((*x)>0) while(file1.read((char*)&book1,sizeof(struct book)))
if(*x==book1.id)
{
j=1;
booktemp=book1;
break;
}
if(*x==0) while(file1.read((char*)&book1,sizeof(struct book)))
if(strcmp(book1.name,n)==0||strcmp(book1.subject,n )==0)
{
j=1;
booktemp=book1;
break;
}
file1.close();
window(10,5,70,20);
textbackground(6);
clrscr();
if(j==0)
{
textcolor(1);
gotoxy(6,7);
cprintf("!!! NOT FOUND THIS BOOK IN THE LIBRARY !!!");
gotoxy(15,10);
cprintf("PRESS ANY KEY TO COMTINUE :");
}
else
{
for(int i=0;i<7;i++)
{
textcolor(1);
gotoxy(2,(i+1)*2);
cprintf("%s",item[i]);
}
gotoxy(8,2);cprintf("%s",book1.name);
gotoxy(10,4);cprintf("%s",book1.writer);
gotoxy(18,6);cprintf("%s",book1.date);
gotoxy(9,8);cout<<book1.price;
gotoxy(13,10);cprintf("%s",book1.publisher);
gotoxy(11,12);cprintf("%s",book1.subject);
gotoxy(7,14);cout<<book1.id;
}
getch();
}
}
//**********************************************
void library::deletmenu(char *key)
{
window(20,9,35,11);
textbackground(1);
textcolor(14);
clrscr();
textcolor(15);
textbackground(3);
gotoxy(2,2);cprintf("Book code :");
gotoxy(2,2);
*key=getch();
}
//********************************
void library::delet()
{
char add[7][20]={
"Name :",
"Writer :",
"Date publisher :",
"Price :","publisher :",
"Subject :",
"Code:"};
char ch;
int code,i,f;
ofstream file2("C:\\temp.dat",ios::in);
if(!file2) cout<<"\ncan not open file";
ifstream file1("C:\\library.dat",ios::out);
if(!file1) cout<<"\ncan not open file";
deletmenu(&ch);
if(ch!=27)
{
gotoxy(13,2);
cin>>code;
}
while(file1.read((char*)&book1,sizeof(struct book)))
{
if(book1.id!=code)
file2.write((char*)&book1,sizeof(struct book));
if(book1.id==code)
{
window(10,5,70,22);
textbackground(1);
textcolor(15);
clrscr();
gotoxy(10,2);cprintf("PLEASE ENTER NEW INFORMATION OF BOOK");cin.get();
gotoxy(2,4);cprintf("%s",add[0]);cin.get(booktemp.name,20);cin.get();
gotoxy(2,6);cprintf("%s",add[1]);cin.get(booktemp.writer,20);cin.get();
gotoxy(2,8);cprintf("%s",add[2]);cin.get(booktemp.date,20);cin.get();
gotoxy(2,10);cprintf("%s",add[3]);cin>>booktemp.price;cin.get();
gotoxy(2,12);cprintf("%s",add[4]);cin.get(booktemp.publisher,20);cin.get();
gotoxy(2,14);cprintf("%s",add[5]);cin.get(booktemp.subject,20);cin.get();
gotoxy(2,16);cprintf("%s",add[6]);cin>>booktemp.id;cin.get();
file2.write((char*)&booktemp,sizeof(struct book));
}
}//end of while
file1.close();
file2.close();
remove("C:\\library.dat");
rename("C:\\temp.dat","C:\\library.dat");
}

سلام.تو این برنامه ک نوشتید قسمتهای قرمزو یه توضیحی بدید لطفا
مرسی

sunyboy
05-30-2012, 05:24 PM
سلام.تو این برنامه ک نوشتید قسمتهای قرمزو یه توضیحی بدید لطفا
مرسی
این برنامه رو باید تحت سیستم عامل داس اجرا کنید. چون اون قسمتهای قرمز رنگ مختصات صفحه و رنگ زمینه رو قید کردند. در کامپایلر تحت ویندوز ممکنه اجرا نشه!!

saeed1313
11-16-2012, 02:45 AM
1-برنامه ای بنویسید که 5 عدد بگیرد و کارهای زیر را انجام دهد:
a)میانگین اعداد را محاسبه کند.
b)ماکزیمم و مینیمم اعداد را چاپ کند.
c)معین کند چند عدد کمتر از 10 میباشد.


2-برنامه ای بنویسید که 100 عدد را خوانده ، تعداد اعداد مثبت و مجموعه اعداد منفی در بین این 100 عدد را محاسبه و چاپ کند .


اگه میشه به زبان c++ برام بنویسید/اگه میشه برام میلش کن/ممنون/

shahram5452
12-10-2012, 07:32 PM
با سلام ضمن خسته نباشید من یک برنامه میخوام که محیط دانشگاه رو با استفاده از کلاس شبیه سازی کنه یعنی قسمت مدیران و قسمت دانشجویان و کارمندان و....

Borna66
12-10-2012, 09:30 PM
1-برنامه ای بنویسید که 5 عدد بگیرد و کارهای زیر را انجام دهد:
a)میانگین اعداد را محاسبه کند.
b)ماکزیمم و مینیمم اعداد را چاپ کند.
c)معین کند چند عدد کمتر از 10 میباشد.


2-برنامه ای بنویسید که 100 عدد را خوانده ، تعداد اعداد مثبت و مجموعه اعداد منفی در بین این 100 عدد را محاسبه و چاپ کند .


اگه میشه به زبان c++ برام بنویسید/اگه میشه برام میلش کن/ممنون/









با سلام ضمن خسته نباشید من یک برنامه میخوام که محیط دانشگاه رو با استفاده از کلاس شبیه سازی کنه یعنی قسمت مدیران و قسمت دانشجویان و کارمندان و....

با سلام

چشم دوستان اگر فراهم سازی شد حتما درج و خدمتون اطلاع رسانی می کنیم ولی قولی در این باره داده نمیشه خدمتون

موفق باشید

روزگار خوش

romina76
12-14-2012, 02:41 AM
سلام بچه از شما یه خواهش داشتم من دنباله مقاله در مورد صادرات پیاز هستم که عوامل قابل کنترل و غیر قابل کنترل صادرات پیاز توش باشه خواهشا کمک کنید تا اخر ماه باید تحویل استاد بدم

romina76
12-14-2012, 02:43 AM
ممنون میشم دو سه روزه جواب بدید ترم اخرم لطفا کمک کنید

leila8
12-28-2012, 08:56 PM
سلام و با آرزوی موفقیت این پرژوه رو در c++ بسیار نیاز دارم پیاده سازی توابع (ضرب و تقسم و تفریق و جمع و پیمانه و توان و ++ و- - برای دو عدد بزرگ مثلا 200رقمی و اینکه آیا یک عدد بزرگ است)

rookielady
01-14-2013, 09:01 PM
سلام
راستش من دانشجوی ترم اول کامپیوترم و این ترم c++ دارم. استادمون هم چند تا برنامه ی مزخرف باهامون کار کرده و حالا به عنوان پروژه برنامه ی انتخاب واحد دانشگاه رو میخواد. من هم چیز زیادی بلد نیستم که بخوام خودم این برنامه رو بنویسم. تا اول بهمن هم بیشتر وقت ندارم. میخواستم ببینم شما میتونید برام بزارینش. لطفاااااا:164::42: واقعا ممنون میشم.

69arrash69
03-28-2013, 12:54 PM
#include<GRAPHICS.H>#include <stdlib.h>
#include <math.h>


void linebres (int x0, int y0, int x1 ,int y1)
{


int dx = fabs (x1 - x0), dy = fabs(y1 - y0);
int p = 2 * dy - dx;
int twody = 2 * dy;
int towdyminusdx = 2 * (dy -dx);
int x;
int y;
if (x0 > x1){
x=x1;
y=y1;
x1=x0;
}
else {
x = x0;
y = y0;
}
setPixel (x, y);
while (x < x0){
x++;
if (p < 0)
p += twody;
else {
y++;
p += towdyminusdx;
}
setPixel (x, y);
}
}




اين الگوريتم رسم خط برزنهام توي كتاب گرفيك رايانه اي (هيرن.بيكر) است با turbo ++c 4.5 اجرا كردم اين اروور روداد
bgi grapgics not suported under windows

mohammad230
12-02-2013, 12:02 PM
با سلام
دنبال یه برنامه به برای محاسبه محیط و مساحت مستطیل با استفاده از کلاس و توابع ( سازنده با پارامتر و بدون پارامتر و کپی و مخرب و ...) و همچنین x واحد به طول و عرض اضافه شود و مجددا برنامه نویسی شود. می گردم .اگه کسی می تونه کمکم کنه ممنون میشم
:104::104:

مهسا6671
10-11-2014, 03:05 PM
سلام مدیر جان می شه لطف کنی برنامه نویسی سی پلاس پلاس وسی شارپ و پایگاه داده وسیستم عامل پیشرفته رواموزش بدین من خیلی نیازمندشم ممنون