質問編集履歴
2
誤字の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -134,7 +134,7 @@
|
|
134
134
|
|
135
135
|
#include <vector>
|
136
136
|
|
137
|
-
|
137
|
+
|
138
138
|
|
139
139
|
|
140
140
|
|
@@ -250,9 +250,149 @@
|
|
250
250
|
|
251
251
|
|
252
252
|
|
253
|
-
double separation = 1 / bins;
|
253
|
+
//double separation = 1 / bins;
|
254
|
+
|
255
|
+
|
256
|
+
|
254
|
-
|
257
|
+
double max_num_hist=0;
|
258
|
+
|
259
|
+
for (auto &elem: vec){
|
260
|
+
|
261
|
+
if ( max_num_hist < elem){
|
262
|
+
|
263
|
+
max_num_hist = elem;
|
264
|
+
|
265
|
+
}
|
266
|
+
|
267
|
+
}
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
double min_num_hist=1;
|
274
|
+
|
275
|
+
for (auto &elem: vec){
|
276
|
+
|
277
|
+
if ( min_num_hist > elem){
|
278
|
+
|
279
|
+
min_num_hist = elem;
|
280
|
+
|
281
|
+
}
|
282
|
+
|
283
|
+
}
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
//std::cout << "max" << max_num_hist << " ";
|
288
|
+
|
289
|
+
//std::cout << "min" << min_num_hist << " ";
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
double separation = (max_num_hist - min_num_hist) / bins;
|
294
|
+
|
295
|
+
//std::cout << "min" << separation << " ";
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
std::vector<int> vect_his;
|
300
|
+
|
301
|
+
for (auto i = 1; i <= bins; ++i){
|
302
|
+
|
303
|
+
vect_his.push_back(0);
|
304
|
+
|
305
|
+
}
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
for (auto &elem: vec){
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
for (auto i = 0; i < bins; ++i){
|
314
|
+
|
315
|
+
if (i==0){
|
316
|
+
|
317
|
+
if ( min_num_hist+separation*(i+1) >= elem){
|
318
|
+
|
319
|
+
vect_his.at(i) += 1;
|
320
|
+
|
321
|
+
}
|
322
|
+
|
323
|
+
}
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
else if ( min_num_hist+separation*(i+1) >= elem && min_num_hist+separation*(i) < elem )
|
328
|
+
|
329
|
+
{
|
330
|
+
|
331
|
+
vect_his.at(i) += 1;
|
332
|
+
|
333
|
+
}
|
334
|
+
|
335
|
+
}
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
}
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
double max_num_freq=0;
|
344
|
+
|
345
|
+
for (auto &elem: vect_his){
|
346
|
+
|
347
|
+
if ( max_num_freq < elem){
|
348
|
+
|
349
|
+
max_num_freq = elem;
|
350
|
+
|
351
|
+
}
|
352
|
+
|
353
|
+
}
|
354
|
+
|
355
|
+
std::cout << std::endl;
|
356
|
+
|
357
|
+
for (auto i = max_num_freq; i > 0; --i){
|
358
|
+
|
359
|
+
for (auto j = 0; j < bins; ++j){
|
360
|
+
|
361
|
+
if (i <= vect_his.at(j) ){
|
362
|
+
|
363
|
+
std::cout << "*** ";
|
364
|
+
|
365
|
+
}
|
366
|
+
|
367
|
+
else{
|
368
|
+
|
369
|
+
std::cout << " ";
|
370
|
+
|
371
|
+
}
|
372
|
+
|
373
|
+
}
|
374
|
+
|
375
|
+
std::cout << std::endl;
|
376
|
+
|
377
|
+
}
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
|
383
|
+
std::cout << "elements: ";
|
384
|
+
|
385
|
+
for (auto &elem: vect_his){
|
386
|
+
|
255
|
-
std::cout << m
|
387
|
+
std::cout << elem << " ";
|
388
|
+
|
389
|
+
//std::cout << vect_his.at(2) << " ";
|
390
|
+
|
391
|
+
}
|
392
|
+
|
393
|
+
std::cout << std::endl;
|
394
|
+
|
395
|
+
|
256
396
|
|
257
397
|
|
258
398
|
|
@@ -308,9 +448,147 @@
|
|
308
448
|
|
309
449
|
|
310
450
|
|
311
|
-
double separation = 1 / bins;
|
451
|
+
//double separation = 1 / bins;
|
452
|
+
|
453
|
+
|
454
|
+
|
312
|
-
|
455
|
+
double max_num_hist=0;
|
456
|
+
|
457
|
+
for (auto &elem: vec){
|
458
|
+
|
459
|
+
if ( max_num_hist < elem){
|
460
|
+
|
461
|
+
max_num_hist = elem;
|
462
|
+
|
463
|
+
}
|
464
|
+
|
465
|
+
}
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
double min_num_hist=1;
|
472
|
+
|
473
|
+
for (auto &elem: vec){
|
474
|
+
|
475
|
+
if ( min_num_hist > elem){
|
476
|
+
|
477
|
+
min_num_hist = elem;
|
478
|
+
|
479
|
+
}
|
480
|
+
|
481
|
+
}
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
//std::cout << "max" << max_num_hist << " ";
|
486
|
+
|
487
|
+
//std::cout << "min" << min_num_hist << " ";
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
double separation = (max_num_hist - min_num_hist) / bins;
|
492
|
+
|
493
|
+
//std::cout << "min" << separation << " ";
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
std::vector<int> vect_his;
|
498
|
+
|
499
|
+
for (auto i = 1; i <= bins; ++i){
|
500
|
+
|
501
|
+
vect_his.push_back(0);
|
502
|
+
|
503
|
+
}
|
504
|
+
|
505
|
+
|
506
|
+
|
507
|
+
for (auto &elem: vec){
|
508
|
+
|
509
|
+
|
510
|
+
|
511
|
+
for (auto i = 0; i < bins; ++i){
|
512
|
+
|
513
|
+
if (i==0){
|
514
|
+
|
515
|
+
if ( min_num_hist+separation*(i+1) >= elem){
|
516
|
+
|
517
|
+
vect_his.at(i) += 1;
|
518
|
+
|
519
|
+
}
|
520
|
+
|
521
|
+
}
|
522
|
+
|
523
|
+
|
524
|
+
|
525
|
+
else if ( min_num_hist+separation*(i+1) >= elem && min_num_hist+separation*(i) < elem )
|
526
|
+
|
527
|
+
{
|
528
|
+
|
529
|
+
vect_his.at(i) += 1;
|
530
|
+
|
531
|
+
}
|
532
|
+
|
533
|
+
}
|
534
|
+
|
535
|
+
|
536
|
+
|
537
|
+
}
|
538
|
+
|
539
|
+
|
540
|
+
|
541
|
+
double max_num_freq=0;
|
542
|
+
|
543
|
+
for (auto &elem: vect_his){
|
544
|
+
|
545
|
+
if ( max_num_freq < elem){
|
546
|
+
|
547
|
+
max_num_freq = elem;
|
548
|
+
|
549
|
+
}
|
550
|
+
|
551
|
+
}
|
552
|
+
|
553
|
+
std::cout << std::endl;
|
554
|
+
|
555
|
+
for (auto i = max_num_freq; i > 0; --i){
|
556
|
+
|
557
|
+
for (auto j = 0; j < bins; ++j){
|
558
|
+
|
559
|
+
if (i <= vect_his.at(j) ){
|
560
|
+
|
561
|
+
std::cout << "*** ";
|
562
|
+
|
563
|
+
}
|
564
|
+
|
565
|
+
else{
|
566
|
+
|
567
|
+
std::cout << " ";
|
568
|
+
|
569
|
+
}
|
570
|
+
|
571
|
+
}
|
572
|
+
|
573
|
+
std::cout << std::endl;
|
574
|
+
|
575
|
+
}
|
576
|
+
|
577
|
+
|
578
|
+
|
579
|
+
|
580
|
+
|
581
|
+
std::cout << "elements: ";
|
582
|
+
|
583
|
+
for (auto &elem: vect_his){
|
584
|
+
|
313
|
-
std::cout << m
|
585
|
+
std::cout << elem << " ";
|
586
|
+
|
587
|
+
//std::cout << vect_his.at(2) << " ";
|
588
|
+
|
589
|
+
}
|
590
|
+
|
591
|
+
std::cout << std::endl;
|
314
592
|
|
315
593
|
|
316
594
|
|
1
誤字の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -320,9 +320,11 @@
|
|
320
320
|
|
321
321
|
```
|
322
322
|
|
323
|
+
の中で、他の関数の値、min_num, max_num (最小値と最大値) の値を使いたいとき、どのように宣言すればよいでしょうか。。
|
324
|
+
|
323
|
-
|
325
|
+
私の結果のアウトプットは、printHistgram の中で、もう一度最小値と最大値を計算しているため、大変非効率だと感じております。
|
324
|
-
|
326
|
+
|
325
|
-
また、引数は変えられないという条件があり、printHistgram内で、min,max を呼び出したいです。
|
327
|
+
また、引数は変えられないという条件があり、printHistgram内で、min(),max() を呼び出したいです。
|
326
328
|
|
327
329
|
|
328
330
|
|