Latest topics | » tài liệu học lập trinh web của trường ĐHKHTN![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) Tue Feb 21, 2012 7:37 pm by Admin» trang Học anh văn trực tuyến![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) Tue Feb 21, 2012 7:33 pm by Admin» các tên miển đã đăng kí![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) Sat Feb 04, 2012 9:18 am by Admin» Tư duy lập trình![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) Thu Nov 10, 2011 9:06 am by Admin» 10 bí mật hàng đầu về công việc trong ngành CNTT![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) Thu Nov 10, 2011 9:04 am by Admin» Thủ thuật tăng nhanh “nội công” cho sinh viên IT và lập trình viên trẻ![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) Thu Nov 10, 2011 9:02 am by Admin» Một số lời khuyên cho người học IT![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) Thu Nov 10, 2011 9:01 am by Admin» Làm thế nào để học tốt CNTT ở trường đại học?![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) Thu Nov 10, 2011 8:58 am by Admin» 5 Cách để học lập trình nhanh hơn – 5 Ways you can Learning Programming Faster![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) Thu Nov 10, 2011 8:55 am by Admin» Từ điển động từ đi với giới từ - Giới từ theo sau các tính từ![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) Sat Oct 15, 2011 8:15 am by Admin» Các tính từ đi với giới từ "To" kèm theo ví dụ!![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) Sat Oct 15, 2011 8:13 am by Admin» Động từ đi với giới từ ![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) Sat Oct 15, 2011 8:12 am by Admin |
| | kỹ thuật sắp sếp | |
| | Tác giả | Thông điệp |
---|
Admin Admin
![Admin Admin](https://2img.net/i/itest/ranks/default/default6.gif)
![Admin](https://2img.net/u/3315/10/21/55/avatars/1-11.jpg)
Tổng số bài gửi : 127 Join date : 18/03/2011 Age : 32 Đến từ : ๑۩۞۩๑[♥๑۩۞۩๑
![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) | Tiêu đề: kỹ thuật sắp sếp Fri Apr 22, 2011 7:08 am | |
| dưới đây là một số dạng mẫu, các bạn áp dụng với những bài khác có cùng dạng cũng tương tự nha255 Sắp xếp mảng tăng dần - Code:
-
void sapxep(int a[],int n) { for (int i=0;i<n;i++) { for (int j=i+1;j<n;j++) { if (a[i]>a[j]) { int temp=a[i]; a[i] = a[j]; a[j]=temp; } } } }
Được sửa bởi Admin ngày Fri Apr 22, 2011 7:20 am; sửa lần 1. | |
| ![Go down](https://2img.net/i/empty.gif) | | Admin Admin
![Admin Admin](https://2img.net/i/itest/ranks/default/default6.gif)
![Admin](https://2img.net/u/3315/10/21/55/avatars/1-11.jpg)
Tổng số bài gửi : 127 Join date : 18/03/2011 Age : 32 Đến từ : ๑۩۞۩๑[♥๑۩۞۩๑
![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) | Tiêu đề: 258 Sắp xếp số nguyên tố tăng dần nhưng giá trị khác giữ nguyên vị trí Fri Apr 22, 2011 7:09 am | |
| - Code:
-
int SoNguyenTo(int a) { if (a<=1) { return 0; } for (int i=2; i<a; i++) { if (a%i==0) { return 0; } } return 1; } void sapxep(int a[],int n) { for (int i=0;i<n;i++) { if (SoNguyenTo (a[i] ) ==1) { for (int j=i+1;j<n;j++) { if (SoNguyenTo (a[j] ) ==1 && a[i]>a[j]) { int temp=a[i]; a[i] = a[j]; a[j]=temp; } } } } }
| |
| ![Go down](https://2img.net/i/empty.gif) | | Admin Admin
![Admin Admin](https://2img.net/i/itest/ranks/default/default6.gif)
![Admin](https://2img.net/u/3315/10/21/55/avatars/1-11.jpg)
Tổng số bài gửi : 127 Join date : 18/03/2011 Age : 32 Đến từ : ๑۩۞۩๑[♥๑۩۞۩๑
![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) | Tiêu đề: 265 Cho 2 mảng tăng. Hãy trộn thành 1 mảng giảm dần Fri Apr 22, 2011 7:10 am | |
| - Code:
-
void sapxep(int a[],int n) { for (int i=0;i<n;i++) { for (int j=i+1;j<n;j++) { if (a[i]>a[j]) { int temp=a[i]; a[i] = a[j]; a[j]=temp; } } } } void TronMang(int a[], int b[], int c[], int na, int nb, int &nc) { nc = na + nb; sapxep(a,na); //Sap xep tang mang A sapxep(b,nb); //Sap xep tang mang B int vta=na-1, vtb=nb-1; for (int i=0;i<nc;i++) { if (vta >= 0 && vtb >= 0) { if (a[vta] > b[vtb]) { c[i] = a[vta]; vta--; } else { c[i] = b[vtb]; vtb--; } } else if (vtb < 0) { c[i] = a[vta]; vta--; } else { c[i] = b[vtb]; vtb--; } } }
| |
| ![Go down](https://2img.net/i/empty.gif) | | Admin Admin
![Admin Admin](https://2img.net/i/itest/ranks/default/default6.gif)
![Admin](https://2img.net/u/3315/10/21/55/avatars/1-11.jpg)
Tổng số bài gửi : 127 Join date : 18/03/2011 Age : 32 Đến từ : ๑۩۞۩๑[♥๑۩۞۩๑
![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) | Tiêu đề: 263 Sắp xếp số dương tăng dần, âm giảm dần. Vị trí tương đối ko đổi Fri Apr 22, 2011 7:12 am | |
| - Code:
-
void sapxep(int a[],int n) { for (int i=0;i<n;i++) { for (int j=i+1;j<n;j++) { if (a[i]>0 && a[j]>0 && a[i]>a[j]) { int temp=a[i]; a[i] = a[j]; a[j]=temp; } else if (a[i]<0 && a[j]<0 && a[i]<a[j]) { int temp=a[i]; a[i] = a[j]; a[j]=temp; } } } }
| |
| ![Go down](https://2img.net/i/empty.gif) | | Admin Admin
![Admin Admin](https://2img.net/i/itest/ranks/default/default6.gif)
![Admin](https://2img.net/u/3315/10/21/55/avatars/1-11.jpg)
Tổng số bài gửi : 127 Join date : 18/03/2011 Age : 32 Đến từ : ๑۩۞۩๑[♥๑۩۞۩๑
![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) | Tiêu đề: 262 Sắp xếp chẵn, lẻ tăng dần nhưng vị trí tương đối giữa các số ko thay đổi Fri Apr 22, 2011 7:13 am | |
| - Code:
-
void sapxep(int a[],int n) { for (int i=0;i<n;i++) { for (int j=i+1;j<n;j++) { if (((a[i]%2==0 && a[j]%2==0)||(a[i]%2!=0 && a[j]%2!=0)) && a[i]>a[j]) { int temp=a[i]; a[i] = a[j]; a[j]=temp; } } } }
| |
| ![Go down](https://2img.net/i/empty.gif) | | Admin Admin
![Admin Admin](https://2img.net/i/itest/ranks/default/default6.gif)
![Admin](https://2img.net/u/3315/10/21/55/avatars/1-11.jpg)
Tổng số bài gửi : 127 Join date : 18/03/2011 Age : 32 Đến từ : ๑۩۞۩๑[♥๑۩۞۩๑
![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) | Tiêu đề: 261 Sắp xếp số dương tăng dần, các số âm giữ nguyên vị trí Fri Apr 22, 2011 7:14 am | |
| - Code:
-
void sapxep(int a[],int n) { for (int i=0;i<n;i++) { if (a[i]>0) { for (int j=i+1;j<n;j++) { if (a[j]>0 && a[i]>a[j]) { int temp=a[i]; a[i] = a[j]; a[j]=temp; } } } } }
Được sửa bởi Admin ngày Fri Apr 22, 2011 7:16 am; sửa lần 1. | |
| ![Go down](https://2img.net/i/empty.gif) | | Admin Admin
![Admin Admin](https://2img.net/i/itest/ranks/default/default6.gif)
![Admin](https://2img.net/u/3315/10/21/55/avatars/1-11.jpg)
Tổng số bài gửi : 127 Join date : 18/03/2011 Age : 32 Đến từ : ๑۩۞۩๑[♥๑۩۞۩๑
![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) | Tiêu đề: 260 Cho 2 mảng a,b. Hãy cho biết mảng b có phải là hoán vị của mảng a ko? Fri Apr 22, 2011 7:15 am | |
| - Code:
-
void sapxep(int a[],int n) { for (int i=0;i<n;i++) { for (int j=i+1;j<n;j++) { if (a[i]>a[j]) { int temp=a[i]; a[i] = a[j]; a[j]=temp; } } } } void KetQua(int a[],int b[],int na,int nb) { if (na != nb) { printf("ko phai!"); return ; } sapxep(a,na); sapxep(b,nb); for (int i=0;i<na;i++) { if (a[i]!=b[i]) { printf("ko phai"); return; } } printf("phai!"); return; }
| |
| ![Go down](https://2img.net/i/empty.gif) | | Admin Admin
![Admin Admin](https://2img.net/i/itest/ranks/default/default6.gif)
![Admin](https://2img.net/u/3315/10/21/55/avatars/1-11.jpg)
Tổng số bài gửi : 127 Join date : 18/03/2011 Age : 32 Đến từ : ๑۩۞۩๑[♥๑۩۞۩๑
![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) | Tiêu đề: 259 Sắp xếp số hòan thiện giảm dần nhưng giá trị khác giữ nguyên vị trí Fri Apr 22, 2011 7:16 am | |
| - Code:
-
int sohoanthien(int n) { int tong=0; for (int i=1 ; i<n; i++) if(n%i==0) tong = tong + i; if (tong == n) return 1; return 0; } void sapxep(int a[],int n) { for (int i=0;i<n;i++) { if (sohoanthien (a[i] ) ==1) { for (int j=i+1;j<n;j++) { if (sohoanthien (a[j] ) ==1 && a[i]<a[j]) { int temp=a[i]; a[i] = a[j]; a[j]=temp; } } } } }
| |
| ![Go down](https://2img.net/i/empty.gif) | | Sponsored content
![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) | Tiêu đề: Re: kỹ thuật sắp sếp ![kỹ thuật sắp sếp Empty](https://2img.net/i/empty.gif) | |
| |
| ![Go down](https://2img.net/i/empty.gif) | | | kỹ thuật sắp sếp | |
|
Trang 1 trong tổng số 1 trang | |
Similar topics | ![+](https://2img.net/i/empty.gif) |
|
| Permissions in this forum: | Bạn không có quyền trả lời bài viết
| |
| |
| |