Bài tập môn An toàn Bảo mật thông tin - Thực hành phần mật mã
- 页数
- 73
- 格式
- 大小
- 2.1 MB
- 语言
- VI · Tiếng Việt
- 浏览量
- 3,402
- 评论
- 0
- 下载次数
- 2
正在生成预览...
- 文档名称
- Bài tập môn An toàn Bảo mật thông tin - Thực hành phần mật mã
- 目录
- 此文档没有清晰的目录。
- 页数
- 73 页
- 上传者
- ThiNganHang
正在生成详细摘要。请几分钟后回来查看。
描述
Trích nội dung tài liệu
BÀI TẬP THỰC HÀNH PHẦN MẬT MÃ (12 tiêt) Bài 1 : Kiểm tra số nguyên tố : #include <iostream.h> #include <conio.h> void main() { clrscr(); int x , n; cout<<"nhap vao so nguyen can kiem tra: ";cin>>x; n=2; while(x%n>0) { n++; } if (n==x ) cout<<"La so nguyen to"; else cout<<"Khongla so NT"; getch(); } Bài 2 :Tạo N số nguyên tố đầu tiên #include <stdio.h> #include <math.h> #define N 100 int i,j,k; long int q,r,n,pr[N+1]; int main() { pr[1]=2;n=3;j=1; label1:j++;pr[j]=n; if (j==N) goto label4; label2: n+=2;k=2; label3: q=n/pr[k];r=n%pr[k]; if(r==0) goto label2; if (q<=pr[k]) goto label1; k++;goto label3 ; label4: for(i=1;i<=N;i++) { printf("%1d ",pr[i]); if(i%10==0) printf(" "); } getchar(); return(n,j,k); }/*main*/ Bài 3 Biểu diễn theo cơ số B /*BIEU DIEN CO SO B*/ #include<stdio.h> #include<math.h> /* input : two non_negative intergers a,b ,b>=2 output : base b representation of a */ int a,b; long repre(int a,int b); long repre0(int a,int b); void main() { a=12;b=2; repre(a,b); a=8;b=4; repre(a,b); a=15245;b=32; repre(a,b); a=748;b=16; repre(a,b); a=14;b=2; repre0(a,b); getchar(); }/* main */ long repre(int a,int b) { int n,i,A[20];long x,q; n=0;q=a/b;A[n]=a%b; while(q>0) { n++;x=q;q=x/b;A[n]=x%b; }/* end while */ printf("a=%1d b=%1d n=%1d\n " ,a,b,n); for(i=0;i<=n;i++) printf(" A[%d]=%1d\n ",i,A[i]); } /* b-representation */ long repre0(int a,int b) { int A0,A1; A0=a%b;A1=(a/b)%b; printf("a=%ld d=%1d A0=%1d A1=%1d ",a,b,A0,A1); }/* b-representation */ Bài 4 : Cộng hai số biểu diễn theo cơ số B #include<stdio.h> #include<math.h> /* input : Two positive integers x,y in base b representation output : x+y in base b representation */ long a,b,x,y,z,t; int A[100],X[100],Y[100],Z[100],i,n,N; long repre(long a,long b); long add(long x,long y); void main() { x=2748;y=659260;b=32; a=x; /*printf("a=%d b=%d x=%d y=%d \n",a,b,x,y);*/ repre(a,b); N=n; for(i=0;i<=n;i++) X[i]=A[i]; a=y;repre(a,b);if(N<n) N=n; for(i=0;i<=n;i++) Y[i]=A[i]; printf("x=%ld y=%ld b=%ld N=%d \n",x,y,b,N); for(i=0;i<=N;i++) printf("X[%d]=%d Y[%d]=%d \n",i,X[i],i,Y[i]); add(x,y); for(i=0;i<=N;i++) printf("Z[%d]=%d \n",i,Z[i]); /* verification */ z=Z[0];t=1; for(i=1;i<=N+1;i++) {t*=b;z+=(Z[i]*t);} printf("z=%ld x+y=%ld \n",z,x+y);getchar(); }/* main */ long repre(long a,long b) { long q,qq ; n=0 ; q =a/b ; A[n]=a%b ; while(q>0) {n++ ; qq=q ; q=qq/b ; A[n]=qq%b;} } /* b - representation */ long add(long x,long y) { int ii,c=0,tem; /* c is the carry digit */ for(ii=0;ii<=n;ii++) { tem=(X[ii]+Y[ii]+c); if(tem<b) {Z[ii]=tem;c=0;} else {Z[ii]=tem-b;c=1;} }/* ii */ Z[N+1]=c; }/* add */ Bài 5 Nhân hai số theo cơ số B # include<stdio.h> # include<math.h>
常见问题
我该如何下载此文档?
文档“Bài tập môn An toàn Bảo mật thông tin - Thực hành phần mật mã”的价格为 35,000đ。请通过 PayOS 充值您的钱包,然后点击“下载”以购买并保存原始文件。
这份文档有多少页?
该文档共有 73 页。您可以在下载前进行在线预览。
我可以在下载前预览吗?
是的。您可以通过在线阅读器直接在本页面预览此文档(前几页),然后再决定是否下载。
Bài tập môn An toàn Bảo mật thông tin - Thực hành phần mật mã
正在生成预览...
Trích nội dung tài liệu
BÀI TẬP THỰC HÀNH PHẦN MẬT MÃ (12 tiêt) Bài 1 : Kiểm tra số nguyên tố : #include <iostream.h> #include <conio.h> void main() { clrscr(); int x , n; cout<<"nhap vao so nguyen can kiem tra: ";cin>>x; n=2; while(x%n>0) { n++; } if (n==x ) cout<<"La so nguyen to"; else cout<<"Khongla so NT"; getch(); } Bài 2 :Tạo N số nguyên tố đầu tiên #include <stdio.h> #include <math.h> #define N 100 int i,j,k; long int q,r,n,pr[N+1]; int main() { pr[1]=2;n=3;j=1; label1:j++;pr[j]=n; if (j==N) goto label4; label2: n+=2;k=2; label3: q=n/pr[k];r=n%pr[k]; if(r==0) goto label2; if (q<=pr[k]) goto label1; k++;goto label3 ; label4: for(i=1;i<=N;i++) { printf("%1d ",pr[i]); if(i%10==0) printf(" "); } getchar(); return(n,j,k); }/*main*/ Bài 3 Biểu diễn theo cơ số B /*BIEU DIEN CO SO B*/ #include<stdio.h> #include<math.h> /* input : two non_negative intergers a,b ,b>=2 output : base b representation of a */ int a,b; long repre(int a,int b); long repre0(int a,int b); void main() { a=12;b=2; repre(a,b); a=8;b=4; repre(a,b); a=15245;b=32; repre(a,b); a=748;b=16; repre(a,b); a=14;b=2; repre0(a,b); getchar(); }/* main */ long repre(int a,int b) { int n,i,A[20];long x,q; n=0;q=a/b;A[n]=a%b; while(q>0) { n++;x=q;q=x/b;A[n]=x%b; }/* end while */ printf("a=%1d b=%1d n=%1d\n " ,a,b,n); for(i=0;i<=n;i++) printf(" A[%d]=%1d\n ",i,A[i]); } /* b-representation */ long repre0(int a,int b) { int A0,A1; A0=a%b;A1=(a/b)%b; printf("a=%ld d=%1d A0=%1d A1=%1d ",a,b,A0,A1); }/* b-representation */ Bài 4 : Cộng hai số biểu diễn theo cơ số B #include<stdio.h> #include<math.h> /* input : Two positive integers x,y in base b representation output : x+y in base b representation */ long a,b,x,y,z,t; int A[100],X[100],Y[100],Z[100],i,n,N; long repre(long a,long b); long add(long x,long y); void main() { x=2748;y=659260;b=32; a=x; /*printf("a=%d b=%d x=%d y=%d \n",a,b,x,y);*/ repre(a,b); N=n; for(i=0;i<=n;i++) X[i]=A[i]; a=y;repre(a,b);if(N<n) N=n; for(i=0;i<=n;i++) Y[i]=A[i]; printf("x=%ld y=%ld b=%ld N=%d \n",x,y,b,N); for(i=0;i<=N;i++) printf("X[%d]=%d Y[%d]=%d \n",i,X[i],i,Y[i]); add(x,y); for(i=0;i<=N;i++) printf("Z[%d]=%d \n",i,Z[i]); /* verification */ z=Z[0];t=1; for(i=1;i<=N+1;i++) {t*=b;z+=(Z[i]*t);} printf("z=%ld x+y=%ld \n",z,x+y);getchar(); }/* main */ long repre(long a,long b) { long q,qq ; n=0 ; q =a/b ; A[n]=a%b ; while(q>0) {n++ ; qq=q ; q=qq/b ; A[n]=qq%b;} } /* b - representation */ long add(long x,long y) { int ii,c=0,tem; /* c is the carry digit */ for(ii=0;ii<=n;ii++) { tem=(X[ii]+Y[ii]+c); if(tem<b) {Z[ii]=tem;c=0;} else {Z[ii]=tem-b;c=1;} }/* ii */ Z[N+1]=c; }/* add */ Bài 5 Nhân hai số theo cơ số B # include<stdio.h> # include<math.h>
- 文档名称
- Bài tập môn An toàn Bảo mật thông tin - Thực hành phần mật mã
- 目录
- 此文档没有清晰的目录。
- 页数
- 73 页
- 上传者
- ThiNganHang
正在生成详细摘要。请几分钟后回来查看。
评论 (0)
暂无评论。快来抢沙发吧!
Ngân hàng đề thi môn: Hệ thống thông tin quản lý
Đề thi môn Cơ sở dữ liệu (kèm Đáp án) - Đại học Sư phạm kỹ thuật
Đề thi và đáp án môn Hệ thống thông tin kế toán
Đề thi và đáp án môn Cấu trúc dữ liệu giải thuật
Đáp án đề thi môn Mạng máy tính - ĐH Công nghệ thông tin (CNTT)
Tiểu luận - Kinh tế phát triển - Phân tích nhận định "Việt Nam đã kiên định chọn hướng phát triển lấy con người làm trọng tâm ..."
Đề cương - Luật vận tải
600 Câu trắc nghiệm Tư tưởng Hồ Chí Minh
Tài liệu ôn tập Nguyên lý kế toán
Bài tập Xác suất thống kê đại học - có lời giải

评论 (0)
暂无评论。快来抢沙发吧!