Đảo mảng với vòng lặp for

#include<iostream> using namespace std; #include<stdio.h> int main() { int a[5]={1,2,3,4,5}; int i=0,j=4,c; cout<<"day so cu 1 2 3 4 5";cout<<"\n"; cout<<"day so moi:";cout<<"\n"; cout<<"\n\r"; for(;c=a[i],a[i]=a[j],a[j]=c,i++<j;)// van mat bieu thuc 3 thay vi viet i<5 ta viet i-5// for(i=0;printf("%8.2f",a[i],i<5);); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.