#include
#include
#include
#include
using namespace std;
1.//就是儲存有關的題,對輸入的陣列,儲存,加以一定的約束判斷,給出答案
const
int maxn =
100010
;bool hashtable[maxn]=;
intmain()
for(
int i =
0; i < m; i++
)else
}system
("pause");
return0;
}/*const int maxn = 100010;
int hashtable[maxn]=;
int main()
for(int i = 0; i < m; i++)
system("pause");
return 0;}*/
2.//盈利的那道題 與錢有關
struct mooncake cake[
1010];
bool cmp
(mooncake a, mooncake b)
intmain()
//printf("c");
for(
int i =
0; i < n; i++
)sort
(cake,cake+n,cmp)
;double money =0;
//收益;
for(
int i =
0; i < n;i++
)else
}printf
("%.2f"
,money)
;//.1f 表示保留小數點後面一位 .2f表示保留小數點後面兩位
system
("pause");
return0;
}/*int cmp(int a, int b)
int main()
sort(arr,arr+10,cmp);
if(arr[0] == 0)} }
for(int i = 0; i < 10; i++)
system("pause");
return 0;}
*/3.
//二分查詢
intbinarysearch
(int a,
int left,
int right,
int x)
else
}return-1
;}intmain()
;printf
("%d %d\n"
,binarysearch
(a,0
, n-1,
6),binarysearch
(a,0
, n-1,
9));
system
("pause");
return0;
}
2020.5.2/週六
by 922
python語言篇(2練習3)
4.列印1 20的整數,每行5個數,列印四行,如 1 2 3 4 5 6 7 8 9 10 提示需要嵌入if語句來列印換行符 n i 1 while i 20 print i,end 列印完畢後,再判斷是否能被5整除 如果能被整除列印換行符 if i 5 0 print i 1 5.用while 語...
c語言練習3
3 編寫一程式,把m n矩陣a的元素逐列按降序排列。假設m n不超過10。分別編寫求一維陣列元素值最大和元素值最小的函式,主函式中初始化乙個二維陣列a 10 10 呼叫定義的兩函式輸出每行 每列的最大值和最小值。程式1 include stdio.h int max int a int min in...
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...