Announcement
Collapse
No announcement yet.
Hàm QuickSort viết bằng 1 dòng lệnh
Collapse
X
-
viết cả một dự án lên 1 dòng cũng đc mà, =))Phạm Minh Tâm
Phone: 01643-652-922
Skype ID: tampham47@live.com
Comment
-
Originally posted by 08520522 View PostSức mạnh của Ruby:
Code:qsort1 = lambda { |lst| if lst.size <=1 then lst else qsort1.call(lst.select{|x| x < lst[0]}) + [lst[0]] + qsort1.call(lst.select{|x| x > lst[0]}) end } qsort1.call([1, 5, 6, 3, 7]) ==> [1, 3, 5, 6, 7]
Python chỉ indent thôi .
Comment
-
cũng vô ích, viết kiểu này lúc fix bugs hay maintenance sếp chửi cho mà ngheBùm, Maria Ozawa Bin Laden, chuyên gia cưa bom hàng đầu Việt Nam
Bùm, Maria Ozawa Bin Laden, chuyên gia cưa bom hàng đầu Việt Nam
Bùm, Maria Ozawa Bin Laden, chuyên gia cưa bom hàng đầu Việt Nam
Bùm, Maria Ozawa Bin Laden, chuyên gia cưa bom hàng đầu Việt Nam
...
Comment
-
power of C++
Code:#include<stdio.h> void quicksort(int [10],int,int); int main() { int x[20],n,i; printf("So luong phan tu: "); scanf("%d",&n); for(i=0;i<n;i++) { printf("Nhap vao phan tu a[%d] ",i); scanf("%d",&x[i]); } quicksort(x,0,n-1); printf("Mang sau khi duoc sap xep la: "); for(i=0;i<n;i++) printf(" %d",x[i]); return 0; } void quicksort(int x[10],int first,int last){ int pivot,j,temp,i; if(first<last){ pivot=first; i=first; j=last; while(i<j){ while(x[i]<=x[pivot]&&i<last) i++; while(x[j]>x[pivot]) j--; if(i<j){ temp=x[i]; x[i]=x[j]; x[j]=temp; } } temp=x[pivot]; x[pivot]=x[j]; x[j]=temp; quicksort(x,first,j-1); quicksort(x,j+1,last); } }
ngôn ngữ này cũng ghê ha, mai học mới được)
Comment
Comment