تمرینات و مثالهای ++C
سورس کدهای درس ++C
++C
تمرینات و مثالهای اجرا شده درس ++C
#include<iostream.h>
#include<conio.h>
#include<string.h>
//*********** Variable *********
int n;
//********** Struct Bank *******
struct bank
{
int mojody,shh;
short int state;
char nam[15],fam[15],adress[50],tel[11];
}*moshtary;
//********** Void's ***********
void input();
void del();
void list();
void rich();
int serch();
void variz();
void bardasht();
void sort();
void menu();
//********** Main **************
int main()
{
menu();
getch();
return 0;
}
//********* input ************
void input()
{
cout<<"_____________________________"<<endl;
cout<<"Shomareh hesab : ";
cin>>moshtary[n].shh;
cout<<"Name : ";
cin>>moshtary[n].nam;
cout<<"Family : ";
cin>>moshtary[n].fam;
cout<<"Tel: ";
cin>>moshtary[n].tel;
cout<<"Enter Money : ";
cin>>moshtary[n].mojody;
cout<<endl<<"_____________________________"<<endl;
n = n + 1 ;
}
//********* List *************
void list()
{
int i;
for(i=0;i<n;i++)
if(moshtary[i].state !=-1)
{
cout<<"_____________________________"<<endl;
cout<<"Shomare hesab : " <<moshtary[i].shh<<endl;
cout<<"name : "<<moshtary[i].nam<<endl;
cout<<"family : "<<moshtary[i].fam<<endl;
cout<<"Telphone : "<<moshtary[i].tel<<endl;
cout<<"Your money : "<<moshtary[i].mojody<<endl;
cout<<"_____________________________"<<endl;
}
}
//********* Menu *************
void menu()
{
moshtary=new bank[n];
while(1)
{
short int ans;
cout<<"_______________________________"<<endl;
cout<<"1 ) Add a customer "<<endl;
cout<<"2 ) Report a customer "<<endl;
cout<<"3 ) Delete a customer "<<endl;
cout<<"4 ) Pickup payment "<<endl;
cout<<"5 ) Settle payment "<<endl;
cout<<"6 ) List "<<endl;
cout<<"7 ) Sort "<<endl;
cout<<"_______________________________"<<endl;
cout<<"Choice your work in list (1-7) : ";
cin>>ans;
switch (ans)
{
case 1:
input();
break;
/* case 2:
serch();
break;
case 3:
del();
break;
case 4:
bardasht();
break;
case 5:
variz();
break;*/
case 6:
list();
break;
/* case 7:
sort();
break;*/
}
}
}