01/10/2018, 13:52
Cần giải thích đoạn if trong code in mảng theo thứ tự giảm dần
// in ra so tu lon den be
#include<stdio.h>
#include<conio.h>
int main() {
int a,n[100],i,j,v;
printf("nhap gia tri"); scanf("%d",&a);
for (i=0;i<a;i++) scanf("%d",&n[i]);
for (i=0;i<a-1;i++)
for(j=i+1;j<a;j++)
{
if (n[i]<n[j]) {
v=n[i];
n[i]=n[j];
n[j]=v;
}
}
for (j=0;j<a;j++) printf("%d ",n[j]);
}
đoạn n[j]=n[i]
rồi n[i]=n[j] ==> tráo đổi số cho nhau biết mỗi nhiêu đó
rồi printf ra n[j] là sao ấy nhỉ ^^
Bài liên quan
(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)
Thớt hỏi code C, bạn up code C++ vào làm gì?