演算法競賽入門經典第二版 第一章例題

2022-08-20 15:33:14 字數 1138 閱讀 5518

輸入底面半徑r和高h,輸出圓柱體的表面積,保留三位小數,格式:

樣例輸入:

3.5 9

樣例輸出:

area = 274.889

**:

#include #include int main()

輸入乙個三位數,分離出它的百位、十位和個位,反轉後輸出。

樣例輸入:

127樣例輸出:

721

**:

#include int main()

輸入兩個整數ab,交換二者的值,然後輸出。

樣例輸入:

824 16

樣例輸出:

16 824

**:

#include int main()

已知雞和兔的總數量為n,總腿數為m。輸入nm每一次輸出雞的數目和兔的數目。如果無解,則輸出no answer

樣例輸入:

14 32

樣例輸出:

12 2

樣例輸入:

10 16

樣例輸出:

no answer

**:

#include int main()

else

return 0;

}

輸入3個整數,從小到大排序後輸出。

樣例輸入:

20 7 33

樣例輸出:

7 20 33

**:

#include int main()

if (a > c)

if (b > c)

printf("%d %d %d", a, b, c);

}

演算法競賽入門經典第一章

123 4567 891011 1213 1415 1617 1819 2021 2223 2425 2627 2829 3031 3233 3435 3637 3839 4041 4243 4445 4647 4849 5051 5253 5455 5657 5859 6061 6263 6465...

演算法競賽與入門經典 (第一章)

1 1 平均數輸入3個整數,輸出他們的平均值,保留三位小數 include include includeusing namespace std int main 1 2 溫度 include include includeusing namespace std int main 1 3 連續和輸入...

演算法競賽入門經典(第二版) 習題

習題2 5 include int main if 10 n b 10 b 5 確定末位四捨五入的情況 printf d 10 n b 1 else printf d 10 n b return 0 注意 要及時輸出,防止n越界 習題2 6 include void result int num,i...