我只想计算最大值并在用户输入时输出。我被困住了,任何帮助都会受到赞赏。
df['subset_max'] = ''
for idx in abnormal_idx:
idx_max = df[idx-5:idx+6].X.idxmax()
#note the +6 instead of +5 as the upbound is not consider, sorry for that
if idx == idx_max:
df.loc[idx,'subset_max'] = 'max of the subset'
else:
df.loc[idx, 'subset_max'] = 'subset max at %s' % idx_max
答案 0 :(得分:1)
如评论中所述,您忘了添加花括号。试试这个...
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
int totalnum, number, num1, max, min;
System.out.println("How many integers are you entering?");
totalnum = Integer.parseInt(input.readLine());
System.out.println("Enter an integer");
number = Integer.parseInt(input.readLine());
max = number;
for (int ctr = 2; ctr <= totalnum; ctr++)
{
number = Integer.parseInt(input.readLine());
if (number > max){
max = number;
}
}
System.out.println("The max is "+ max);
答案 1 :(得分:0)
IMO,没有必要使用ec2:Describe*
来进行此类输入。我更喜欢使用void __fastcall Tdata::bcServerExecute(TIdContext *AContext)
{
String json = AContext->Connection->Socket->ReadLn();
TJSONObject* jo = (TJSONObject*)TJSONObject::ParseJSONValue(json);
if (jo != 0)
{
TJSONPair* jp = (TJSONPair*)jo->Get("text");
String text = jp->JsonValue->Value();
jp = (TJSONPair*)jo->Get("font_size");
int font_size = _wtoi(jp->JsonValue->Value().c_str());
int tw = 0;
double text_width = 0.0;
//================================
TCanvas* canvas = new TCanvas();
if (canvas)
{
canvas->Handle = GetDC(0);
canvas->Font->Size = font_size;
tw = canvas->TextWidth(text);
double ppi = Screen->PixelsPerInch;
text_width = double(tw) / ppi;
ReleaseDC(0,canvas->Handle);
delete canvas;
}
String buf = String(text_width);
//==================================
AContext->Connection->IOHandler->WriteLn(buf);
}
}
。
无论如何,只是为了提供一个替代答案,你可以阅读List
和Collections
,或许给你的同事/同学/讲师等留下深刻印象。
例如:
BufferedReader
* 为了简单起见,我只是默认为5