fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. double time[] = {26.7, 26.8, 26.9, 27.0, 27.1, 27.2, 27.3, 27.4, 27.5,
  5. 27.6, 27.7, 27.8, 27.9, 28.0, 28.1, 28.2, 28.3, 28.4,
  6. 28.5, 28.6, 28.7, 28.8, 28.9, 29.0, 29.1};
  7. double voltage[] = {3.508688, 3.549394, 3.579923, 3.610453, 3.618085, 3.592644,
  8. 3.554482, 3.467982, 3.328054, 3.132156, 2.880287, 2.803963,
  9. 2.679301, 2.541918, 2.526653, 2.521565, 2.572447, 2.511388,
  10. 2.496124, 2.592801, 2.725095, 2.898096, 3.152509, 3.254275, 3.325510};
  11.  
  12. int n = sizeof(time) / sizeof(time[0]);
  13.  
  14. printf("ピーク検出結果:\n");
  15. for (int i=1; i < n-1; i++) {
  16. if (voltage[i] > voltage[i-1] && voltage[i] > voltage[i+1]) {
  17. printf("時刻=%.3f秒, 電位=%.3fV\n", time[i], voltage[i]);
  18. }
  19. }
  20.  
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
ピーク検出結果:
時刻=27.100秒, 電位=3.618V
時刻=28.300秒, 電位=2.572V