c語言練習3

2021-05-23 15:06:40 字數 424 閱讀 1221

3、

編寫一程式,把m×n矩陣a的元素逐列按降序排列。假設m、n不超過10。分別編寫求一維陣列元素值最大和元素值最小的函式,主函式中初始化乙個二維陣列a[10][10],呼叫定義的兩函式輸出每行、每列的最大值和最小值。

程式1:

#include"stdio.h"

int max(int a)

int min(int a)

void swap(int *p1,int *p2)

main()

for(i=0;i<10;i++)

for(j=i;j<10;j++)

swap(&a[i][j],&a[j][i]); /*行列變換*/

for(k=0;k<10;k++) /*相當於列迴圈*/

} 注意一維陣列與二維陣列的不同,位址屬性的區別。

C語言練習3

1.猜數字遊戲。define crt secure no warnings include include include int menu void game else if num guess num else printf 猜低了 n int main else if choice 0 els...

3 C語言練習

給定兩個整形變數的值,將兩個值的內容進行交換。define crt secure no deprecate include include int main 執行結果為 2.不允許建立臨時變數,交換兩個數的內容 附加題 define crt secure no deprecate include i...

c語言練習篇(3)

include include include include using namespace std 1.就是儲存有關的題,對輸入的陣列,儲存,加以一定的約束判斷,給出答案 const int maxn 100010 bool hashtable maxn intmain for int i 0 ...