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ã
- Pages
- 73
- Format
- Size
- 2.1 MB
- Language
- VI · Tiếng Việt
- Views
- 3,402
- Comments
- 0
- Lượt tải
- 2
Generating preview...
- Document name
- 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ã
- Table of contents
- This document has no clear table of contents.
- Pages
- 73 pages
- Uploaded by
- ThiNganHang
A detailed summary is being generated. Please check back in a few minutes.
Description
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>
Frequently asked questions
How do I download this document?
The document “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ã” costs 35,000đ. Top up your wallet via PayOS, then click Download to purchase and save the original file.
How many pages is this document?
The document has 73 pages. You can preview it online before downloading.
Can I preview before downloading?
Yes. You can preview this document right on this page with the online reader (first few pages), then decide whether to download.
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ã
Generating preview...
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>
- Document name
- 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ã
- Table of contents
- This document has no clear table of contents.
- Pages
- 73 pages
- Uploaded by
- ThiNganHang
A detailed summary is being generated. Please check back in a few minutes.
Comments (0)
No comments yet. Be the first!
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

Comments (0)
No comments yet. Be the first!