fork download
  1. #include <stdio.h>
  2.  
  3. #define MAX_DATA 1000
  4.  
  5. int main() {
  6. double time[MAX_DATA], value[MAX_DATA];
  7. int count = 0;
  8.  
  9. // データの読み込み
  10. while (scanf("%lf,%lf", &time[count], &value[count]) == 2) {
  11. count++;
  12. if (count >= MAX_DATA) break;
  13. }
  14.  
  15. // ピーク検出と表示
  16. printf("\nピーク時のデータ(時間[秒], 値):\n");
  17. for (int i = 1; i < count - 1; i++) {
  18. if (value[i] > value[i - 1] && value[i] > value[i + 1]) {
  19. printf("%.6f,%.6f\n", time[i], value[i]);
  20. }
  21. }
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0.01s 5292KB
stdin
0.000000,2.335955
0.100000,2.328314
0.200000,2.333408
0.300000,2.328314
0.400000,2.341049
0.500000,2.333408
0.600000,2.325767
0.700000,2.325767
0.800000,2.335955
0.900000,2.338502
1.000000,2.333408
1.100000,2.333408
1.200000,2.333408
1.300000,2.333408
1.400000,2.341049
1.500000,2.333408
1.600000,2.335955
1.700000,2.338502
1.800000,2.343596
1.900000,2.346143
2.000000,2.351236
2.100000,2.366518
2.200000,2.468396
2.300000,2.781672
2.400000,3.163716
2.500000,3.265594
2.600000,3.438787
2.700000,3.609433
2.800000,3.673107
2.900000,3.606886
3.000000,3.313986
3.100000,2.791860
3.200000,2.511695
3.300000,2.437833
3.400000,2.414910
3.500000,2.397082
3.600000,2.384347
3.700000,2.374159
3.800000,2.376706
3.900000,2.374159
4.000000,2.371612
4.100000,2.376706
4.200000,2.402176
4.300000,2.529523
4.400000,3.066931
4.500000,3.591604
4.600000,3.749516
4.700000,3.772438
4.800000,3.716405
4.900000,3.461709
5.000000,2.842799
5.100000,2.537164
5.200000,2.473490
5.300000,2.453115
5.400000,2.460756
5.500000,2.460756
5.600000,2.460756
5.700000,2.450568
5.800000,2.440380
5.900000,2.526976
6.000000,2.814782
6.100000,3.385301
6.200000,3.614527
6.300000,3.688389
6.400000,3.670560
6.500000,3.566135
6.600000,3.161169
6.700000,2.628855
6.800000,2.470943
6.900000,2.427645
7.000000,2.427645
7.100000,2.435286
7.200000,2.437833
7.300000,2.432739
7.400000,2.430192
7.500000,2.488772
7.600000,2.758749
7.700000,3.380207
7.800000,3.576322
7.900000,3.520289
8.000000,3.476991
8.100000,3.410770
8.200000,3.117870
8.300000,2.654324
8.400000,2.473490
8.500000,2.440380
8.600000,2.430192
8.700000,2.445474
8.800000,2.455662
8.900000,2.458209
9.000000,2.521883
9.100000,2.753656
9.200000,3.051649
9.300000,3.265594
9.400000,3.311439
9.500000,3.296157
9.600000,3.245218
9.700000,2.990522
9.800000,2.567728
9.900000,2.460756
10.000000,2.445474
10.100000,2.470943
10.200000,2.478584
10.300000,2.468396
10.400000,2.473490
10.500000,2.468396
10.600000,2.687435
10.700000,3.005804
10.800000,3.145887
10.900000,3.110229
11.000000,3.033821
11.100000,2.868269
11.200000,2.616120
11.300000,2.455662
11.400000,2.425098
11.500000,2.425098
11.600000,2.437833
11.700000,2.450568
11.800000,2.450568
11.900000,2.437833
stdout
ピーク時のデータ(時間[秒], 値):
0.200000,2.333408
0.400000,2.341049
0.900000,2.338502
1.400000,2.341049
2.800000,3.673107
3.800000,2.376706
4.700000,3.772438
6.300000,3.688389
7.200000,2.437833
7.800000,3.576322
9.400000,3.311439
10.200000,2.478584
10.400000,2.473490
10.800000,3.145887