#include <conio.h><br /> #include <stdio.h><br /> <br /> main()<br /> {<br /> <br /> //Trang tri chuong trinh<br /> int i;<br /> printf("\t");<br /> for (i=1;i<30;i++) printf("* ");<br /> printf("\n\t\t CHUONG TRINH DAO NGUOC MOT MANG\n\n");<br /> //Het doan chuong trinh trang tri<br /> <br /> int n;<br /> <br /> printf("\t- Nhap vao so phan tu: "); scanf("%d",&n);<br /> <br /> int a[n];<br /> <br /> printf("\n");<br /> <br /> for (i=1;i<=n;i++)<br /> {<br /> printf("\t- Nhap vao phan tu a[%d]: ",i);<br /> scanf("%d",&a[i]);<br /> }<br /> <br /> printf("\n\n");<br /> <br /> printf("\t=> Mang ban da nhap: \n\t");<br /> for (i=1;i<=n;i++)<br /> printf("%d ",a[i]);<br /> <br /> <br /> <br /> printf("\n\n");<br /> <br /> printf("\t=> Mang sau khi dao chieu: \n\t");<br /> <br /> int val;<br /> for (i=1;i<=n/2;i++)<br /> {<br /> val=a[i];<br /> a[i]=a[n-i+1];<br /> a[n-i+1]=val; <br /> <br /> }<br /> <br /> <br /> for (i=1;i<=n;i++)<br /> printf("%d ",a[i]);<br /> <br /> <br /> getch();<br /> return 0;<br /> }<
0 nhận xét:
Đăng nhận xét