for-loop

    2熱度

    2回答

    我有如圖逗號分隔的數字數組: 一個:{108,109,110,112,114,115,116,118} 我所需要的輸出是這樣的: 一個:{108-110,112,114-116,118} 我試圖將連續的數字與之間的「 - 」進行分組。 例如,108,109,110是連續數字,所以我得到108-110。 112是單獨的條目; 114,115,116再次代表一個序列,所以我得到114-116。 118

    0熱度

    1回答

    我有需要顯示輸入到系統中,我有現在的方法是什麼投標歷史的方法是: @Override public String displayHistory() { String bidder = toString(); if (this.bids.isEmpty()) { return bidder + " = no bids"; } for (int i

    0熱度

    1回答

    我正在編寫shell腳本來替換數據庫中的名稱,爲此,我有用戶列表中的當前名稱和新名稱在.txt文件中。文件格式是像下面 **new name current name** abc pqr def stq mnd tdh 對於這個我寫個「for循環」使用awk命令,在這裏我想它應該給我的$1即abc值,def,mnd等 我寫下如下循環, function() { c

    -2熱度

    3回答

    我試圖在兩者之間的if-and-else語句中創建一些Java代碼。當我運行代碼時,預期輸出應該是:「hello world hello world」,但我得到的是「hello hello hello hello」 我不知道我在這裏做錯了什麼。有人可以告訴我這個問題嗎? int p = 1; for (int i = 1; i < 5; i++) { if (p == 1) {

    3熱度

    2回答

    有人可能有任何想法如何將其替換爲stream()? for (Customer customer : customers) { if (customer.getProducts() != null && customer.getProducts().getProduct() != null) { for (Product product : customer.getProdu

    1熱度

    3回答

    我需要實現一個for循環,該循環從一個浮點數轉到另一個浮點數。 我知道如何實現,在C類語言: for (float i = -1.0; i < 1.0; i += 0.01) { /* ... */ } 我也知道,在魯斯特我可以指定使用step_by循環一步,這給了我我想要的,如果我有邊界價值觀和步爲整數: #![feature(iterator_step_by)] fn main() {

    9熱度

    1回答

    爲什麼不按照我的假設工作? for (auto it: *std::make_unique<std::vector<int>>(std::vector<int>({1, 2, 3, 4, 5}))) std::cout << it << std::endl; 的矢量對象執行循環的第一次迭代之前銷燬

    0熱度

    4回答

    我有一個Python字典,看起來像這樣。 {0: {'record': u'running fast', 'moreInfo': u'test', 'year': u'2017', 'name': u'Jose la computadora', 'activity': u'Cross Country'}, 1: {'record': u'test', 'moreInfo': u'ttt', 'ye

    1熱度

    1回答

    我前幾天正在處理這個問題,但是我找不到答案。希望您能夠幫助我。 這是我的數據框: Date Attribute Quantity 0 2017-12-14 large -39 0 2017-12-15 large -80 1 2017-12-15 large -30 2 2017-12-14 short -15 2 2017-12-15 sho

    -3熱度

    1回答

    好吧,我有這個問題:如果不想工作,我不知道爲什麼。 該程序應該從文件中取一些數字,首先指出第二行上的數字的數量,並說明該行上的最小值和最大值。 #include <iostream> #include <fstream> using namespace std; int main() { ifstream f("file.in"); ofstream g("file.out");