出于某种原因,"总计+ = i;"不会工作,当我回去"总计"它返回0。
[{"time"=>1512460800, "summary"=>"Clear throughout the day.", "icon"=>"clear-day", "sunriseTime"=>1512486716, "sunsetTime"=>1512521519, "moonPhase"=>0.58, "precipIntensity"=>0.0001, "precipIntensityMax"=>0.0006, "precipIntensityMaxTime"=>1512500400, "precipProbability"=>0.06, "precipType"=>"rain", "temperatureHigh"=>64.54, "temperatureHighTime"=>1512514800, "temperatureLow"=>47.44, "temperatureLowTime"=>1512572400, "apparentTemperatureHigh"=>64.54, "apparentTemperatureHighTime"=>1512514800, "apparentTemperatureLow"=>44.22, "apparentTemperatureLowTime"=>1512572400, "dewPoint"=>30.15, "humidity"=>0.39, "pressure"=>1023.77, "windSpeed"=>1.68, "windGust"=>8.69, "windGustTime"=>1512460800, "windBearing"=>5, "cloudCover"=>0, "uvIndex"=>2, "uvIndexTime"=>1512500400, "visibility"=>10, "ozone"=>297.16, "temperatureMin"=>48.29, "temperatureMinTime"=>1512486000, "temperatureMax"=>64.54, "temperatureMaxTime"=>1512514800, "apparentTemperatureMin"=>48.29, "apparentTemperatureMinTime"=>1512486000, "apparentTemperatureMax"=>64.54, "apparentTemperatureMaxTime"=>1512514800}, {"time"=>1512547200, "summary"=>"Clear throughout the day.", "icon"=>"clear-day", "sunriseTime"=>1512573168, "sunsetTime"=>1512607917, "moonPhase"=>0.62, "precipIntensity"=>0.0001, "precipIntensityMax"=>0.0003, "precipIntensityMaxTime"=>1512561600, "precipProbability"=>0.09, "precipType"=>"rain", "temperatureHigh"=>62.86, "temperatureHighTime"=>1512604800, "temperatureLow"=>48.56, "temperatureLowTime"=>1512658800, "apparentTemperatureHigh"=>62.86, "apparentTemperatureHighTime"=>1512604800, "apparentTemperatureLow"=>43.79, "apparentTemperatureLowTime"=>1512658800, "dewPoint"=>34.95, "humidity"=>0.48, "pressure"=>1025.29, "windSpeed"=>6.22, "windGust"=>16.92, "windGustTime"=>1512583200, "windBearing"=>46, "cloudCover"=>0, "uvIndex"=>2, "uvIndexTime"=>1512586800, "visibility"=>10, "ozone"=>278.87, "temperatureMin"=>47.44, "temperatureMinTime"=>1512572400, "temperatureMax"=>62.86, "temperatureMaxTime"=>1512604800, "apparentTemperatureMin"=>44.22, "apparentTemperatureMinTime"=>1512572400, "apparentTemperatureMax"=>62.86, "apparentTemperatureMaxTime"=>1512604800}, {"time"=>1512633600, "summary"=>"Partly cloudy starting in the evening.", "icon"=>"partly-cloudy-night", "sunriseTime"=>1512659619, "sunsetTime"=>1512694317, "moonPhase"=>0.66, "precipIntensity"=>0, "precipIntensityMax"=>0.0002, "precipIntensityMaxTime"=>1512698400, "precipProbability"=>0, "temperatureHigh"=>63.83, "temperatureHighTime"=>1512687600, "temperatureLow"=>48.42, "temperatureLowTime"=>1512745200, "apparentTemperatureHigh"=>63.83, "apparentTemperatureHighTime"=>1512687600, "apparentTemperatureLow"=>44.92, "apparentTemperatureLowTime"=>1512745200, "dewPoint"=>33.82, "humidity"=>0.44, "pressure"=>1028.91, "windSpeed"=>7.95, "windGust"=>25.41, "windGustTime"=>1512658800, "windBearing"=>55, "cloudCover"=>0.18, "uvIndex"=>2, "uvIndexTime"=>1512673200, "visibility"=>10, "ozone"=>258.06, "temperatureMin"=>48.56, "temperatureMinTime"=>1512658800, "temperatureMax"=>63.83, "temperatureMaxTime"=>1512687600, "apparentTemperatureMin"=>43.79, "apparentTemperatureMinTime"=>1512658800, "apparentTemperatureMax"=>63.83, "apparentTemperatureMaxTime"=>1512687600}, {"time"=>1512720000, "summary"=>"Mostly cloudy throughout the day.", "icon"=>"partly-cloudy-day", "sunriseTime"=>1512746069, "sunsetTime"=>1512780719, "moonPhase"=>0.69, "precipIntensity"=>0.0001, "precipIntensityMax"=>0.0001, "precipIntensityMaxTime"=>1512734400, "precipProbability"=>0.07, "precipType"=>"rain", "temperatureHigh"=>61.45, "temperatureHighTime"=>1512777600, "temperatureLow"=>48.15, "temperatureLowTime"=>1512831600, "apparentTemperatureHigh"=>61.45, "apparentTemperatureHighTime"=>1512777600, "apparentTemperatureLow"=>44.44, "apparentTemperatureLowTime"=>1512831600, "dewPoint"=>34.61, "humidity"=>0.47, "pressure"=>1031.01, "windSpeed"=>5.99, "windGust"=>13.87, "windGustTime"=>1512756000, "windBearing"=>51, "cloudCover"=>0.77, "uvIndex"=>1, "uvIndexTime"=>1512752400, "visibility"=>10, "ozone"=>269.7, "temperatureMin"=>48.42, "temperatureMinTime"=>1512745200, "temperatureMax"=>61.45, "temperatureMaxTime"=>1512777600, "apparentTemperatureMin"=>44.92, "apparentTemperatureMinTime"=>1512745200, "apparentTemperatureMax"=>61.45, "apparentTemperatureMaxTime"=>1512777600}, {"time"=>1512806400, "summary"=>"Partly cloudy in the morning.", "icon"=>"partly-cloudy-night", "sunriseTime"=>1512832517, "sunsetTime"=>1512867123, "moonPhase"=>0.73, "precipIntensity"=>0, "precipIntensityMax"=>0.0001, "precipIntensityMaxTime"=>1512806400, "precipProbability"=>0, "temperatureHigh"=>62.74, "temperatureHighTime"=>1512864000, "temperatureLow"=>50.62, "temperatureLowTime"=>1512918000, "apparentTemperatureHigh"=>62.74, "apparentTemperatureHighTime"=>1512864000, "apparentTemperatureLow"=>50.62, "apparentTemperatureLowTime"=>1512918000, "dewPoint"=>35.49, "humidity"=>0.49, "pressure"=>1025.93, "windSpeed"=>6.93, "windGust"=>12.55, "windGustTime"=>1512842400, "windBearing"=>48, "cloudCover"=>0.33, "uvIndex"=>2, "uvIndexTime"=>1512846000, "ozone"=>283.11, "temperatureMin"=>48.15, "temperatureMinTime"=>1512831600, "temperatureMax"=>62.74, "temperatureMaxTime"=>1512864000, "apparentTemperatureMin"=>44.44, "apparentTemperatureMinTime"=>1512831600, "apparentTemperatureMax"=>62.74, "apparentTemperatureMaxTime"=>1512864000}, {"time"=>1512892800, "summary"=>"Clear throughout the day.", "icon"=>"clear-day", "sunriseTime"=>1512918964, "sunsetTime"=>1512953528, "moonPhase"=>0.76, "precipIntensity"=>0.0001, "precipIntensityMax"=>0.0003, "precipIntensityMaxTime"=>1512896400, "precipProbability"=>0.08, "precipType"=>"rain", "temperatureHigh"=>62.47, "temperatureHighTime"=>1512950400, "temperatureLow"=>50.61, "temperatureLowTime"=>1513004400, "apparentTemperatureHigh"=>62.47, "apparentTemperatureHighTime"=>1512950400, "apparentTemperatureLow"=>50.61, "apparentTemperatureLowTime"=>1513004400, "dewPoint"=>34.72, "humidity"=>0.45, "pressure"=>1023.18, "windSpeed"=>7.76, "windGust"=>16.21, "windGustTime"=>1512928800, "windBearing"=>54, "cloudCover"=>0, "uvIndex"=>2, "uvIndexTime"=>1512932400, "ozone"=>282.43, "temperatureMin"=>50.62, "temperatureMinTime"=>1512918000, "temperatureMax"=>62.47, "temperatureMaxTime"=>1512950400, "apparentTemperatureMin"=>50.62, "apparentTemperatureMinTime"=>1512918000, "apparentTemperatureMax"=>62.47, "apparentTemperatureMaxTime"=>1512950400}, {"time"=>1512979200, "summary"=>"Clear throughout the day.", "icon"=>"clear-day", "sunriseTime"=>1513005410, "sunsetTime"=>1513039936, "moonPhase"=>0.8, "precipIntensity"=>0, "precipIntensityMax"=>0, "precipProbability"=>0, "temperatureHigh"=>64.19, "temperatureHighTime"=>1513033200, "temperatureLow"=>48.85, "temperatureLowTime"=>1513090800, "apparentTemperatureHigh"=>64.19, "apparentTemperatureHighTime"=>1513033200, "apparentTemperatureLow"=>46.51, "apparentTemperatureLowTime"=>1513090800, "dewPoint"=>36.65, "humidity"=>0.48, "pressure"=>1025.06, "windSpeed"=>4.75, "windGust"=>11.56, "windGustTime"=>1513015200, "windBearing"=>38, "cloudCover"=>0, "uvIndex"=>2, "uvIndexTime"=>1513018800, "ozone"=>315.21, "temperatureMin"=>50.61, "temperatureMinTime"=>1513004400, "temperatureMax"=>64.19, "temperatureMaxTime"=>1513033200, "apparentTemperatureMin"=>50.61, "apparentTemperatureMinTime"=>1513004400, "apparentTemperatureMax"=>64.19, "apparentTemperatureMaxTime"=>1513033200}, {"time"=>1513065600, "summary"=>"Clear throughout the day.", "icon"=>"clear-day", "sunriseTime"=>1513091855, "sunsetTime"=>1513126347, "moonPhase"=>0.83, "precipIntensity"=>0.0001, "precipIntensityMax"=>0.0003, "precipIntensityMaxTime"=>1513069200, "precipProbability"=>0.08, "precipType"=>"rain", "temperatureHigh"=>63.42, "temperatureHighTime"=>1513119600, "temperatureLow"=>49.53, "temperatureLowTime"=>1513177200, "apparentTemperatureHigh"=>63.42, "apparentTemperatureHighTime"=>1513119600, "apparentTemperatureLow"=>47.18, "apparentTemperatureLowTime"=>1513177200, "dewPoint"=>36.66, "humidity"=>0.49, "pressure"=>1023.65, "windSpeed"=>4.19, "windGust"=>12.25, "windGustTime"=>1513101600, "windBearing"=>28, "cloudCover"=>0.02, "uvIndex"=>2, "uvIndexTime"=>1513105200, "ozone"=>318.34, "temperatureMin"=>48.85, "temperatureMinTime"=>1513090800, "temperatureMax"=>63.42, "temperatureMaxTime"=>1513119600, "apparentTemperatureMin"=>46.51, "apparentTemperatureMinTime"=>1513090800, "apparentTemperatureMax"=>63.42, "apparentTemperatureMaxTime"=>1513119600}]
如果你运行它,无论输入是什么,答案是0.我所有其他数字都是正确的,我很确定它与for循环有关。
答案 0 :(得分:0)
你的total += i
没有任何效果,因为它永远不会被执行!
在尝试进入循环之前打印的special
和limit
的值是多少?
答案 1 :(得分:0)
试试这个循环:
for(int i = special; i >= limit; i -= 2){
total += i;
}