C語言基礎練習4

2021-08-09 13:10:56 字數 987 閱讀 5960

1.用陣列來處理求fibonacci數列問題

#includeint main()

; for (i = 2; i < 20; i++)

f[i] = f[i - 2] + f[i - 1];

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

printf("\n");

return 0;

}

2.起泡法排序10個數

#includeint main()

printf("the sorted number :\n");

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

printf("%d ", a[i]);

printf("\n");

return 0;

}

3.求3x4矩陣中值最大的元素的值,及其所在的行與列

#includeint main()

,, };

max = a[0][0];

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

for(j=0;j<=3;j++)

if (a[i][j] > max)

printf("max=%d\nrow=%d\ncolum=%d\n", max, row, colum);

return 0;

}

4.輸入一行字元,統計有多少個單詞,單詞之間用空格分開

#includeint main()

printf("there are %d words in this line.\n", num);

return 0;

}

5.有3個字串,要求找出其中最大者

#include#includeint main()

C語言基礎練習

1 判斷年份是否是閏年 include int main else 如果輸入的年份能整除4但不能整除100或者能整除400就是閏年 return 0 2 判斷是否是素數 include int main printf n return0 int prime int n return 1 判斷素數函式...

C語言基礎練習

1.在螢幕上輸出以下圖案 水仙花數 是指乙個三位數,其各位數字的立方和確好等於該數本身,如 153 1 5 3?則153是乙個 水仙花數 在數論中,水仙花數 narcissistic number 也稱為自戀數 自冪數 阿姆斯壯數或阿姆斯特朗數 armstrong number 是指一n位數,其各個...

練習4 c 基礎

using system using system.collections.generic using system.linq using system.text namespace列舉 列舉可用來儲存字串與數字的值對,相當於乙個對照表 常用方法 getname getvalue parse 宣告乙...