C Exercise Example 90
100 cases of classic C language
Topic: Upgraded a problem, read the results.
Program Analysis: None.
Source Code:
// Created by www.w3big.com on 15/11/9. // Copyright © 2015年 本教程. All rights reserved. // #include<stdio.h> #include<stdlib.h> #define M 5 int main() { int a[M]={1,2,3,4,5}; int i,j,t; i=0;j=M-1; while(i<j) { t=*(a+i); *(a+i)=*(a+j); *(a+j)=t; i++;j--; } for(i=0;i<M;i++) { printf("%d\n",*(a+i)); } }
Run the above example output is:
5 4 3 2 1