147 統計各年齡段人數

2021-07-03 14:20:47 字數 720 閱讀 7334

函式fun的功能是:統計各年齡段的人數,n個年齡通過呼叫隨機函式獲取,並放在主函式的age陣列中,要求函式0-9歲的人數放在d[0],以此類推,把100歲(含100歲)以上的年齡人數都放在d[10]中,結構在主函式中輸出。

#define _crt_secure_no_warnings

#include#define n 50

#define m 11

void fun(int *a, int *b)

double rnd()

int main()

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

age[i] = (int)(115 * rnd());

printf("the orignal data:\n");

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

printf((i + 1) % 10 == 0 ? "%4d\n" : "%4d", age[i]);

printf("\n\n");

fun(age, d);

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

printf("%4d--%4d:%4d\n", i * 10, i * 10 + 9, d[i]);

printf("over 100 : %4d\n", d[10]);

system("pause");

return 0;

}

sql 年齡段統計

表employee empid,birthday 部分資料 empid birthday 1 1964 3 2 2 1980 5 9 3 1972 9 30 想得到按年齡段的人數,比如說20 30歲的員工數,30 40歲的員工數,40 50歲的員工數,50歲以上的員工數 即由員工表得到以下的統計資料...

mysql根據出生日期統計各年齡段男女人數

名稱 user,字段 id,m 表示男,f表示 女 birthday出生日期,沒有 age欄位 其中round datediff curdate birthday 365.2422 是獲得 年齡 case when的格式是 case when 條件 then 結果 when 條件 then 結果 w...

MySQL按年齡段查詢

下面是專案中按照男女年齡段統計的核心sql sql view plain copy print count tr.id as 體檢總人數 sum case when s.1 then 1 else 0 end as 男體檢總數 sum case when s.0 then 1 else 0 end ...