當前位置:編程學習大全網 - 編程軟體 - 數據交換編程

數據交換編程

我寫完才發現妳在樓上說VB,但是我不會。我給妳C語言,思路應該差不多。

其思路是用temp數組保存第壹行的數據,然後用最後壹行的數據覆蓋第壹行,最後將temp的數據賦給最後壹行,實現互換。

運行結果:

# include & ltstdio.h & gt

int main(){

int a[2][4]={

{1,2,3,4},

{5,6,7,8}

};

Printf("原始數組:\ n ");

for(int I = 0;我& lt2;i++){

for(int j = 0;j & lt4;j++){

printf("%d ",a[I][j]);

}

printf(" \ n ");

}

int temp[1][4]= { 0 };

for(int j = 0;j & lt4;j++){

temp[0][j]= a[0][j];

a[0][j]= a[1][j];

a[1][j]= temp[0][j];

}

Printf("新數組是:\ n ");

for(int I = 0;我& lt2;i++){

for(int j = 0;j & lt4;j++){

printf("%d ",a[I][j]);

}

printf(" \ n ");

}

}

  • 上一篇:徑流調節計算的基本方法
  • 下一篇:周五夜放克玩法介紹
  • copyright 2024編程學習大全網