100題 第六題

2021-08-26 11:44:49 字數 489 閱讀 2840

舉乙個例子,

數值: 0,1,2,3,4,5,6,7,8,9

分配: 6,2,1,0,0,0,1,0,0,0

0在下排出現了6次,1在下排出現了2次,

2在下排出現了1次,3在下排出現了0次....

以此類推..

一,暴力破解法

#includeusing namespace std; const int len = 10; int main() int count_times[len]; bool success = false, result = true; while (!success) //不成功時候 if (count_times[i] != count) } success = result; } for (j = 0; j < len; j++) cout << count_times[j] << " "; return 0; }

VJ第六題題解

輸入三個字元後,按各字元的ascii碼從小到大的順序輸出這三個字元。input 輸入資料有多組,每組佔一行,有三個字元組成,之間無空格。output 對於每組輸入資料,輸出一行,字元中間用乙個空格分開。sample input qweasd zxcsample output e q w a d s ...

尤拉計畫 第六題

前十個自然數的平方和是 1 2 2 2 10 2 385 前十個自然數的和的平方是 1 2 10 2 55 2 3025 所以平方和與和的平方的差是3025 找出前一百個自然數的平方和與和平方的差。原始碼 stdmethodimp coula test6 int number for int i 1...

類與物件第六題

定義乙個圓類 circle 其所在的包為bzu.info.software 定義乙個圓柱類cylinder,其所在的包為bzu.info.com 定義乙個主類a,其所在的包也為bzu.info.com,在a中生成乙個cylinder物件,並輸出其體積。編譯並執行該類。試著改變求體積方法的訪問許可權,...