位置: 首页 > 资讯 > 正文

百度之星程序设计大赛官网(百度之星)

2023-06-09 13:03:46 来源:


(相关资料图)

今天小编宋丹来为大家解答以上的问题。百度之星程序设计大赛官网,百度之星相信很多小伙伴还不知道,现在让我们一起来看看吧!

1、//不理解提示说的什么意思...= =! #include #define _DEBUG_MODE_ int MaxIntersperseValue(int *arr, int count) { int result = 0; for (int i = 0; i < count; i++) { #ifdef _DEBUG_MODE_ printf("arr[%d]: %d", i, arr[i]); #endif if (arr[i] >0) result++; arr[i] = arr[i] - 1; } #ifdef _DEBUG_MODE_ printf("Result: %d", result); #endif return result; } bool ValidCheck(int *arr, int count, int expectedSum) { int sum = 0; for (int i = 0; i < count; i++) { sum += arr[i]; } if (sum == expectedSum) return true; return false; } int main() { int n;//app count int m;//dev count int *apps; printf("Please input application count(n) & developer count(m):"); scanf("%d", &n); scanf("%d", &m); apps = new int[m]; printf("Please input the application count that each developer owns:"); for (int i = 0; i < m; i++) { scanf("%d", apps + i); } if (ValidCheck(apps, m, n) == false) { printf("Count of input applications is not matched with the application count(n: %d)", n); delete[] apps; return 0; } int previousInt = 0; int currentInt = 0; int result = 0; while ((currentInt = MaxIntersperseValue(apps, m)) >0) { #ifdef _DEBUG_MODE_ printf("Current: %d", currentInt); #endif result += previousInt * currentInt; previousInt = currentInt; } printf("Max Intersperse Value is: %d", result); delete[] apps; }。

本文就为大家分享到这里,希望小伙伴们会喜欢。

关键词:

上一篇:应对突发 “救”在身边!九江市150多名环卫工人又多了一项技能-天天短讯
下一篇:最后一页