fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. double time[1000], voltage[1000];
  5. int n = 0;
  6. double t, v;
  7.  
  8. while (scanf("%lf,%lf", &t, &v) == 2) {
  9. if (t >= 10.0 && t <= 20.0) {
  10. time[n] = t;
  11. voltage[n] = v;
  12. n++;
  13. }
  14. }
  15.  
  16. printf("波形番号\t時刻[秒]\t電位[V]\n");
  17. int peak_count = 1;
  18. for (int i = 1; i < n - 1; i++) {
  19. if (voltage[i] > voltage[i-1] && voltage[i] > voltage[i+1] && voltage[i] >= 3.0) {
  20. printf("%d\t\t%.1f\t\t%.2f\n", peak_count, time[i], voltage[i]);
  21. peak_count++;
  22. }
  23. }
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 5324KB
stdin
0.000000,2.353917
0.100000,2.359012
0.200000,2.359012
0.300000,2.353917
0.400000,2.351370
0.500000,2.366655
0.600000,2.366655
0.700000,2.359012
0.800000,2.366655
0.900000,2.364107
1.000000,2.366655
1.100000,2.364107
1.200000,2.359012
1.300000,2.356465
1.400000,2.351370
1.500000,2.359012
1.600000,2.356465
1.700000,2.356465
1.800000,2.364107
1.900000,2.348822
2.000000,2.356465
2.100000,2.356465
2.200000,2.346275
2.300000,2.348822
2.400000,2.343727
2.500000,2.353917
2.600000,2.353917
2.700000,2.356465
2.800000,2.353917
2.900000,2.356465
3.000000,2.361560
3.100000,2.359012
3.200000,2.364107
3.300000,2.351370
3.400000,2.369202
3.500000,2.473652
3.600000,2.888901
3.700000,3.334720
3.800000,3.566546
3.900000,3.665901
4.000000,3.660805
4.100000,3.696471
4.200000,3.686281
4.300000,3.579284
4.400000,3.281222
4.500000,2.720763
4.600000,2.471104
4.700000,2.420153
4.800000,2.412511
4.900000,2.404868
5.000000,2.415058
5.100000,2.448176
5.200000,2.389583
5.300000,2.389583
5.400000,2.460914
5.500000,3.059586
5.600000,3.541071
5.700000,3.640425
5.800000,3.561451
5.900000,3.551261
6.000000,3.533428
6.100000,3.507953
6.200000,3.515596
6.300000,3.416242
6.400000,3.153845
6.500000,2.761524
6.600000,2.598481
6.700000,2.496579
6.800000,2.440534
6.900000,2.435438
7.000000,2.427796
7.100000,2.397225
7.200000,2.417606
7.300000,2.402320
7.400000,2.491484
7.500000,2.639242
7.600000,2.978065
7.700000,3.459550
7.800000,3.648068
7.900000,3.678638
8.000000,3.716851
8.100000,3.767802
8.200000,3.742327
8.300000,3.762707
8.400000,3.757612
8.500000,3.655710
8.600000,3.380576
8.700000,2.863425
8.800000,2.697835
8.900000,2.613766
9.000000,2.460914
9.100000,2.529697
9.200000,2.473652
9.300000,2.437986
9.400000,2.394678
9.500000,2.570458
9.600000,3.194606
9.700000,3.446812
9.800000,3.734684
9.900000,3.660805
10.000000,3.653163
10.100000,3.411147
10.200000,3.059586
10.300000,2.978065
10.400000,2.702930
10.500000,2.603576
10.600000,2.468556
10.700000,2.463461
10.800000,2.397225
10.900000,2.399773
stdout
波形番号	時刻[秒]	電位[V]