#include <stdio.h> void dia(int a[], int n)/*数组传的其实是地址*/ { int i; for(i=0;i<n;i++) { if(a[i]%2==0) a[i]*=2; else a[i]*=3; } } main() { int x[8]={11,12,13,14,15,16,17,18},i; dia(x,8); for(i=0;i<8;i++)printf("%3d",x[i]); getchar(); }
#include <stdio.h> void dia(int a[], int n)/*数组传的其实是地址*/ { int i; for(i=0;i<n;i++) { if(a[i]%2==0) a[i]*=2; else a[i]*=3; } } main() { int x[8]={11,12,13,14,15,16,17,18},i; dia(x,8); for(i=0;i<8;i++)printf("%3d",x[i]); getchar(); }