當前位置:首頁 » 課程設計 » 銀行安全防範系統課程設計

銀行安全防範系統課程設計

發布時間: 2020-11-18 04:38:30

Ⅰ C語言課程設計銀行管理小系統

我這有個個人收支管理系統,你看看是否用得上。
#include<stdio.h>
#include<string.h>
#define N 100
struct money
{
int shunxu;
int year;
int month;
int day;
char zhaiyao[50];
float jine;
float yue;
char bizhong[10];
int biao;

}in[N],out[N],temp[N],*pp,*qq;
void shouru(int x)
{

int i;
char ch;
system("cls");
if(x==1)
pp=in;
else
pp=out;
for(i=1;i<N;i++,pp++)
{
pp->shunxu=i;
pp->biao=x;
printf("\n日期(年 月 日)\t摘要\t金額\t幣種\n");
scanf("%d%d%d%s%f%s",&pp->year,&pp->month,&pp->day,pp->zhaiyao,&pp->jine, pp->bizhong );
printf("是否繼續輸入?1 是 2 否\n");
scanf("%s",&ch);
if(ch=='1')
continue;
else if(ch=='2')
break;
else
{

printf("error!");
system("pause");
break;
}

}
printf("是否保存:1是 2否\n");
scanf("%d",&i);
switch(i)
{
case 1:
if(x==1)
{
xieru(1);
break;
}
else
{
xieru(-1);
break;
}
case 2:
system("pause");
break;
default:
break;
}

}
mingxi()
{
FILE *f;
int y,m,d,y2,m2,d2;
int i;
system("cls");
pp=temp;
if((f=fopen("ff.txt","rt"))==NULL)
{
printf("文件打開錯誤!");
system("pause");
}
for(i=0;i<N;i++,pp++)
fscanf(f,"%d\t%d年%d月%d日\t%s\t%f\t%f\t%s\t%d\n",&pp->shunxu,&pp->year,&pp->month,&pp->day,pp->zhaiyao,&pp->jine,&pp->yue,pp->bizhong,&pp->biao);
pp=temp;
/*for(;pp->shunxu!=0;pp++)
printf("%d %s %f\n",pp->shunxu,pp->bizhong,pp->jine);*/
printf("輸入起止時間(年 月 日):\n");
scanf("%d%d%d%d%d%d",&y,&m,&d,&y2,&m2,&d2);
for(;pp->shunxu!=0;pp++)
{
if(pp->year>=y||pp->month>=m||pp->day>=d)
{

for(;pp->shunxu!=0;pp++)
{

if(pp->year>y2||pp->month>m2||pp->day>d2)
break;
printf("%d年%d月%d日\t%f\n",pp->year,pp->month,pp->day,pp->jine);
}
}

}

system("pause");

}
chaxun()
{
system("cls");
printf("建設中。。。");
system("pause");
}
xieru(int x)
{
FILE *f;
system("cls");
pp=in;
qq=out;
f=fopen("ff.txt","at+");
if(f==NULL)
{
printf("文件打開錯誤!");
system("pause");
}
if(x==1)
for(;pp->shunxu !=0;pp++)
{
fprintf(f,"%d\t%d年%d月%d日\t%s\t%f\t%f\t%s\t%d\n",pp->shunxu,pp->year,pp->month,pp->day,pp->zhaiyao,pp->jine,pp->yue,pp->bizhong,pp->biao);

}
else if(x==-1)
for(;qq->shunxu!=0;qq++)
{
fprintf(f,"%d\t%d年%d月%d日\t%s\t%f\t%f\t%s\t%d\n",qq->shunxu,qq->year,qq->month,qq->day,qq->zhaiyao,qq->jine,qq->yue,qq->bizhong,qq->biao);
}
else
{
for(;pp->shunxu !=0;pp++)
{
fprintf(f,"%d\t%d年%d月%d日\t%s\t%f\t%f\t%s\t%d\n",pp->shunxu,pp->year,pp->month,pp->day,pp->zhaiyao,pp->jine,pp->yue,pp->bizhong,pp->biao);

}
for(;qq->shunxu!=0;qq++)
{
fprintf(f,"%d\t%d年%d月%d日\t%s\t%f\t%f\t%s\t%d\n",qq->shunxu,qq->year,qq->month,qq->day,qq->zhaiyao,qq->jine,qq->yue,qq->bizhong,qq->biao);
}
}

fclose(f);
printf("保存成功!");
system("pause");
}
qu()
{
FILE *f;
char ch;
system("cls");

f=fopen("ff.txt","rb");
if(f==NULL)
{
printf("文件打開錯誤!");
system("pause");
}
ch=fgetc(f);
while(ch!=EOF)
{
putchar(ch);
ch=fgetc(f);
}
fclose(f);
system("pause");
}

void main()
{
int i=1,a;
for(;i!=0;)
{
system("cls");
printf("個人收支管理\n");
printf("1.收入\n2.支出\n3.明細表\n4.查詢與統計\n5.寫入文件\n6.讀取文件\n0.退出\n");
scanf("%d",&a);
switch(a)
{
case 1:
shouru(1);
break;
case 2:
shouru(-1);
break;
case 3:
mingxi();
break;
case 4:
chaxun();
break;
case 5:
xieru(0);
break;
case 6:
qu();
break;
case 0:
i=0;
break;

}

}

}

Ⅱ 操作系統課程設計任務書:銀行家演算法設計

#include<stdio.h>
#include<stdlib.h>
struct type
{
int a;
int b;
int c;
};
struct allocation
{
struct type value;
struct allocation *next;
};
struct max
{
struct type value;
struct max *next;
};
struct available
{
struct type value;
struct available *next;
};
struct need
{
struct type value;
struct need *next;
};
struct path
{
int value;
struct path *next;
};
struct finish
{
int value;
struct finish *next;
};

void main()
{
int p,status=0,i,j,temp,flag=0;
struct allocation *allochead,*alloc1,*alloc2,*alloctemp;
struct max *maxhead,*max1,*max2,*maxtemp;
struct available *availablehead,*workhead,*worktemp;
struct need *needhead,*need1,*need2,*needtemp;
struct path *pathhead,*path1,*path2,*pathtemp;
struct finish *finishhead,*finish1,*finish2,*finishtemp;

printf("請輸入進程的數目\n");
scanf("%d",&p);
for(i=0;i<p;i++)
{
printf("\n輸入進程p%d已經分配的資源\n",i+1);
if(flag==0)
{
allochead=alloc1=alloc2=(struct allocation*)malloc(sizeof(struct allocation));
printf("\t當前資源類型是 %c\t",'a');
scanf("%d",&alloc1->value.a);
printf("\t當前資源類型是 %c\t",'b');
scanf("%d",&alloc1->value.b);
printf("\t當前資源類型是 %c\t",'c');
scanf("%d",&alloc1->value.c);
flag++;
allochead=alloc1;
}
else
{
alloc2=(struct allocation*)malloc(sizeof(struct allocation));
printf("\t當前資源類型是 %c\t",'a');
scanf("%d",&alloc2->value.a);
printf("\t當前資源類型是 %c\t",'b');
scanf("%d",&alloc2->value.b);
printf("\t當前資源類型是 %c\t",'c');
scanf("%d",&alloc2->value.c);

alloc1->next=alloc2;
alloc1=alloc2;
flag++;
}
}
alloc2->next=NULL;
flag=0;

for(i=0;i<p;i++)
{
printf("\n輸入進程p%d要求的最大數目\n",i+1);
if(flag==0)
{
maxhead=max1=max2=(struct max*)malloc(sizeof(struct max));
printf("\t當前資源類型是 %c\t",'a');
scanf("%d",&max1->value.a);
printf("\t當前資源類型是 %c\t",'b');
scanf("%d",&max1->value.b);
printf("\t當前資源類型是 %c\t",'c');
scanf("%d",&max1->value.c);
maxhead=max1;
flag++;
}
else
{
max2=(struct max*)malloc(sizeof(struct max));
printf("\t當前資源類型是 %c\t",'a');
scanf("%d",&max2->value.a);
printf("\t當前資源類型是 %c\t",'b');
scanf("%d",&max2->value.b);
printf("\t當前資源類型是 s %c\t",'c');
scanf("%d",&max2->value.c);
max1->next=max2;
max1=max2;
flag++;
}
}
max2->next=NULL;
flag=0;

printf("\n請輸入可以利用是資源數目\n");
availablehead=workhead=(struct available*)malloc(sizeof(struct available));
printf("\n");
printf("\t當前資源類型是 %c\t",'a');
scanf("%d",&availablehead->value.a);
printf("\t當前資源類型是 %c\t",'b');
scanf("%d",&availablehead->value.b);
printf("\t當前資源類型是 %c\t",'c');
scanf("%d",&availablehead->value.c);
workhead=availablehead;
workhead->value=availablehead->value;
flag=0;

alloctemp=allochead;
maxtemp=maxhead;
for(i=0;i<p;i++)
{
if(flag==0)
{
needhead=need1=need2=(struct need*)malloc(sizeof(struct need));
need1->next=need2->next=NULL;
need1->value.a=(maxtemp->value.a)-(alloctemp->value.a);
need1->value.b=(maxtemp->value.b)-(alloctemp->value.b);
need1->value.c=(maxtemp->value.c)-(alloctemp->value.c);
needhead=need1;
flag++;
}
else
{
need2=(struct need*)malloc(sizeof(struct need));
need2->value.a=(maxtemp->value.a)-(alloctemp->value.a);
need2->value.b=(maxtemp->value.b)-(alloctemp->value.b);
need2->value.c=(maxtemp->value.c)-(alloctemp->value.c);

need1->next=need2;
need1=need2;
flag++;
}
maxtemp=maxtemp->next;
alloctemp=alloctemp->next;
}
need2->next=NULL;
flag=0;

for(i=0;i<p;i++)
{
if(flag==0)
{
finishhead=finish1=finish2=(struct finish*)malloc(sizeof(struct finish));
finish1->next=finish2->next=NULL;
finish1->value=0;
finishhead=finish1;
flag++;
}
else
{
finish2=(struct finish*)malloc(sizeof(struct finish));
finish2->value=0;

finish1->next=finish2;
finish1=finish2;
flag++;
}
}
finish2->next=NULL;
flag=0;

for(temp=0;temp<p;temp++)
{
alloctemp=allochead;
needtemp=needhead;
finishtemp=finishhead;
worktemp=workhead;

for(j=0;j<p;j++)
{
if(finishtemp->value==0)
{
if((needtemp->value.a<=worktemp->value.a)&&(needtemp->value.b<=worktemp->value.b)&&(needtemp->value.c<=worktemp->value.c))
{
worktemp->value.a+=alloctemp->value.a;
worktemp->value.b+=alloctemp->value.b;
worktemp->value.c+=alloctemp->value.c;
finishtemp->value=1;
if(flag==0)
{
pathhead=path1=path2=(struct path*)malloc(sizeof(struct path));
path1->next=path2->next=NULL;
path1->value=j+1;
pathhead=path1;
flag++;
}
else
{
path2=(struct path*)malloc(sizeof(struct path));
path2->value=j+1;
path1->next=path2;
path1=path2;
flag++;
}
finishtemp=finishtemp->next;
alloctemp=alloctemp->next;
needtemp=needtemp->next;
}
else
{
finishtemp=finishtemp->next;
alloctemp=alloctemp->next;
needtemp=needtemp->next;
}
}
else
{
finishtemp=finishtemp->next;
alloctemp=alloctemp->next;
needtemp=needtemp->next;
}

}
}
path2->next=NULL;
finishtemp=finishhead;
pathtemp=pathhead;
for(temp=0;temp<p;temp++)
{
if(finishtemp->value==0)
{
printf("\n警告!當前系統是不安全的\n");
exit(0);
}
finishtemp=finishtemp->next;
}
printf("\n當前系統是安全的!\n");
printf("\n安全序列為: \n");
for(i=0;i<p;i++)
{
printf("p%d\t",pathhead->value);
pathhead=pathhead->next;
}
}

Ⅲ 銀行家演算法 操作系統課程設計

這個剛做過,直接貼給你好了,給分吧
#include<iostream.h>
#include<string.h>
#include<stdio.h>
#define False 0
#define True 1
int Max[100][100]={0};//各進程所需各類資源的最大需求
int Avaliable[100]={0};//系統可用資源
char name[100]={0};//資源的名稱
int Allocation[100][100]={0};//系統已分配資源
int Need[100][100]={0};//還需要資源
int Request[100]={0};//請求資源向量
int temp[100]={0};//存放安全序列
int Work[100]={0};//存放系統可提供資源
int M=100;//作業的最大數為100
int N=100;//資源的最大數為100
void showdata()//顯示資源矩陣
{
int i,j;
cout<<"系統目前可用的資源[Avaliable]:"<<endl;
for(i=0;i<N;i++)
cout<<name[i]<<" ";
cout<<endl;
for (j=0;j<N;j++)
cout<<Avaliable[j]<<" ";//輸出分配資源
cout<<endl;
cout<<" Max Allocation Need"<<endl;
cout<<"進程名 ";
for(j=0;j<3;j++){
for(i=0;i<N;i++)
cout<<name[i]<<" ";
cout<<" ";
}
cout<<endl;
for(i=0;i<M;i++){
cout<<" "<<i<<" ";
for(j=0;j<N;j++)
cout<<Max[i][j]<<" ";
cout<<" ";
for(j=0;j<N;j++)
cout<<Allocation[i][j]<<" ";
cout<<" ";
for(j=0;j<N;j++)
cout<<Need[i][j]<<" ";
cout<<endl;
}
}

int changdata(int i)//進行資源分配
{
int j;
for (j=0;j<M;j++) {
Avaliable[j]=Avaliable[j]-Request[j];
Allocation[i][j]=Allocation[i][j]+Request[j];
Need[i][j]=Need[i][j]-Request[j];
}
return 1;
}
int safe()//安全性演算法
{
int i,k=0,m,apply,Finish[100]={0};
int j;
int flag=0;
Work[0]=Avaliable[0];
Work[1]=Avaliable[1];
Work[2]=Avaliable[2];
for(i=0;i<M;i++){
apply=0;
for(j=0;j<N;j++){
if (Finish[i]==False&&Need[i][j]<=Work[j]){
apply++;
if(apply==N){
for(m=0;m<N;m++)
Work[m]=Work[m]+Allocation[i][m];//變分配數
Finish[i]=True;
temp[k]=i;
i=-1;
k++;
flag++;
}
}
}
}
for(i=0;i<M;i++){
if(Finish[i]==False){
cout<<"系統不安全"<<endl;//不成功系統不安全
return -1;
}
}
cout<<"系統是安全的!"<<endl;//如果安全,輸出成功
cout<<"分配的序列:";
for(i=0;i<M;i++){//輸出運行進程數組
cout<<temp[i];
if(i<M-1) cout<<"->";
}
cout<<endl;
return 0;
}
void share()//利用銀行家演算法對申請資源對進行判定
{
char ch;
int i=0,j=0;
ch='y';
cout<<"請輸入要求分配的資源進程號(0-"<<M-1<<"):";
cin>>i;//輸入須申請的資源號
cout<<"請輸入進程 "<<i<<" 申請的資源:"<<endl;
for(j=0;j<N;j++)
{
cout<<name[j]<<":";
cin>>Request[j];//輸入需要申請的資源
}
for (j=0;j<N;j++){
if(Request[j]>Need[i][j])//判斷申請是否大於需求,若大於則出錯
{
cout<<"進程 "<<i<<"申請的資源大於它需要的資源";
cout<<" 分配不合理,不予分配!"<<endl;
ch='n';
break;
}
else {
if(Request[j]>Avaliable[j])//判斷申請是否大於當前資源,若大於則
{ //出錯
cout<<"進程"<<i<<"申請的資源大於系統現在可利用的資源";
cout<<" 分配出錯,不予分配!"<<endl;
ch='n';
break;
}
}
}
if(ch=='y') {
changdata(i);//根據進程需求量變換資源
showdata();//根據進程需求量顯示變換後的資源
safe();//根據進程需求量進行銀行家演算法判斷
}
}
void addresources(){//添加資源
int n,flag;
cout<<"請輸入需要添加資源種類的數量:";
cin>>n;
flag=N;
N=N+n;
for(int i=0;i<n;i++){
cout<<"名稱:";
cin>>name[flag];
cout<<"數量:";
cin>>Avaliable[flag++];
}
showdata();
safe();
}
void delresources(){//刪除資源
char ming;
int i,flag=1;
cout<<"請輸入需要刪除的資源名稱:";
do{
cin>>ming;
for(i=0;i<N;i++)
if(ming==name[i]){
flag=0;
break;
}
if(i==N)
cout<<"該資源名稱不存在,請重新輸入:";
}
while(flag);
for(int j=i;j<N-1;j++)
{
name[j]=name[j+1];
Avaliable[j]=Avaliable[j+1];

}
N=N-1;
showdata();
safe();
}
void changeresources(){//修改資源函數
cout<<"系統目前可用的資源[Avaliable]:"<<endl;
for(int i=0;i<N;i++)
cout<<name[i]<<":"<<Avaliable[i]<<endl;
cout<<"輸入系統可用資源[Avaliable]:"<<endl;
cin>>Avaliable[0]>>Avaliable[1]>>Avaliable[2];
cout<<"經修改後的系統可用資源為"<<endl;
for (int k=0;k<N;k++)
cout<<name[k]<<":"<<Avaliable[k]<<endl;
showdata();
safe();
}
void addprocess(){//添加作業
int flag=M;
M=M+1;
cout<<"請輸入該作業的最打需求量[Max]"<<endl;
for(int i=0;i<N;i++){
cout<<name[i]<<":";
cin>>Max[flag][i];
Need[flag][i]=Max[flag][i]-Allocation[flag][i];
}
showdata();
safe();
}
int main()//主函數
{

int i,j,number,choice,m,n,flag;
char ming;
cout<<"*****************資源管理系統的設計與實現*****************"<<endl;
cout<<"請首先輸入系統可供資源種類的數量:";
cin>>n;
N=n;
for(i=0;i<n;i++)
{
cout<<"資源"<<i+1<<"的名稱:";
cin>>ming;
name[i]=ming;
cout<<"資源的數量:";
cin>>number;
Avaliable[i]=number;
}
cout<<endl;
cout<<"請輸入作業的數量:";
cin>>m;
M=m;
cout<<"請輸入各進程的最大需求量("<<m<<"*"<<n<<"矩陣)[Max]:"<<endl;
for(i=0;i<m;i++)
for(j=0;j<n;j++)
cin>>Max[i][j];
do{
flag=0;
cout<<"請輸入各進程已經申請的資源量("<<m<<"*"<<n<<"矩陣)[Allocation]:"<<endl;
for(i=0;i<m;i++)
for(j=0;j<n;j++){
cin>>Allocation[i][j];
if(Allocation[i][j]>Max[i][j])
flag=1;
Need[i][j]=Max[i][j]-Allocation[i][j];
}
if(flag)
cout<<"申請的資源大於最大需求量,請重新輸入!\n";
}
while(flag);

showdata();//顯示各種資源
safe();//用銀行家演算法判定系統是否安全
while(choice)
{
cout<<"**************銀行家演算法演示***************"<<endl;
cout<<" 1:增加資源 "<<endl;
cout<<" 2:刪除資源 "<<endl;
cout<<" 3:修改資源 "<<endl;
cout<<" 4:分配資源 "<<endl;
cout<<" 5:增加作業 "<<endl;
cout<<" 0:離開 "<<endl;
cout<<"*******************************************"<<endl;
cout<<"請選擇功能號:";
cin>>choice;
switch(choice)
{
case 1: addresources();break;
case 2: delresources();break;
case 3: changeresources();break;
case 4: share();break;
case 5: addprocess();break;
case 0: choice=0;break;
default: cout<<"請正確選擇功能號(0-5)!"<<endl;break;
}
}
return 1;
}

Ⅳ 銀行家演算法課程設計

利用銀行家演算法避免鎖 . 銀行家演算法 設Requesti是進程Pi的請求向量,如果Requesti[j]=K,表示進程Pi需要K個Rj類型的資源。當Pi發出資源請求後,系統按下述步驟進行檢查: (1) 如果Requesti[j]≤Need[i,j],便轉向步驟2;否則認為出錯,因為它所需要的資源數已超過它所宣布的最大值。 (2) 如果Requesti[j]≤Available[j],便轉向步驟(3);否則, 表示尚無足夠資源,Pi須等待。 (3) 系統試探著把資源分配給進程Pi,並修改下面數據結構中的數值: Available[j]∶=Available[j]-Requesti[j]; Allocation[i,j]∶=Allocation[i,j]+Requesti[j]; Need[i,j]∶=Need[i,j]-Requesti[j]; (4) 系統執行安全性演算法,檢查此次資源分配後,系統是否處於安全狀態。若安全,才正式將資源分配給進程Pi,以完成本次分配;否則, 將本次的試探分配作廢,恢復原來的資源分配狀態,讓進程Pi等待。 (3) 系統試探著把資源分配給進程Pi,並修改下面數據結構中的數值: Available[j]∶=Available[j]-Requesti[j]; Allocation[i,j]∶=Allocation[i,j]+Requesti[j]; Need[i,j]∶=Need[i,j]-Requesti[j]; (4) 系統執行安全性演算法,檢查此次資源分配後,系統是否處於安全狀態。若安全,才正式將資源分配給進程Pi,以完成本次分配;否則, 將本次的試探分配作廢,恢復原來的資源分配狀態,讓進程Pi等待。 (3) 系統試探著把資源分配給進程Pi,並修改下面數據結構中的數值: Available[j]∶=Available[j]-Requesti[j]; Allocation[i,j]∶=Allocation[i,j]+Requesti[j]; Need[i,j]∶=Need[i,j]-Requesti[j]; (4) 系統執行安全性演算法,檢查此次資源分配後,系統是否處於安全狀態。若安全,才正式將資源分配給進程Pi,以完成本次分配;否則, 將本次的試探分配作廢,恢復原來的資源分配狀態,讓進程Pi等待。

Ⅳ VF銀行賬戶管理系統課程設計的實驗報告怎麼寫

可以藉助Baihi示意我們
有機會能夠處理你所遇到的工作
差不多的要求也能夠示意我們

ES:\\

熱點內容
幼師專業怎麼樣 發布:2021-03-16 21:42:13 瀏覽:24
音樂小毛驢故事 發布:2021-03-16 21:40:57 瀏覽:196
昂立中學生教育閘北 發布:2021-03-16 21:40:47 瀏覽:568
建築業一建報考條件 發布:2021-03-16 21:39:53 瀏覽:666
2017年教師資格注冊結果 發布:2021-03-16 21:39:49 瀏覽:642
中國教師資格證查分 發布:2021-03-16 21:39:41 瀏覽:133
踵什麼成語有哪些 發布:2021-03-16 21:38:20 瀏覽:962
東營幼師專業學校 發布:2021-03-16 21:35:26 瀏覽:467
機械電子研究生課程 發布:2021-03-16 21:33:36 瀏覽:875
杭州朝日教育培訓中心怎麼樣 發布:2021-03-16 21:33:28 瀏覽:238