fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.  
  5. double time[] = {
  6. 14.95,14.96,14.97,14.98,14.99,15.00,15.01,15.02,15.03,15.04,
  7. 15.05,15.06,15.07,15.08,15.09,15.10,15.11,15.12,15.13,15.14,
  8. 15.15,15.16,15.17,15.18,15.19,15.20
  9. };
  10.  
  11. double voltage[] = {
  12. 2.479849,2.484948,2.479849,2.472202,2.477300,2.482399,2.474751,
  13. 2.472202,2.479849,2.482399,2.482399,2.479849,2.472202,2.477300,
  14. 2.484948,2.477300,2.477300,2.472202,2.472202,2.477300,2.479849,
  15. 2.482399,2.477300,2.479849,2.477300,2.484948
  16. };
  17.  
  18. int n = sizeof(voltage) / sizeof(voltage[0]);
  19.  
  20. // ピーク検出
  21. for (int i = 1; i < n - 1; i++) {
  22. if (voltage[i] > voltage[i-1] && voltage[i] > voltage[i+1]) {
  23. printf("Peak: time = %.2f s, voltage = %.2f V\n", time[i], voltage[i]);
  24. }
  25. }
  26.  
  27. return 0;
  28. }-- your code goes here
Success #stdin #stdout #stderr 0s 5312KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Error: near line 3: near "int": syntax error
Error: near line 11: near "double": syntax error
Error: near line 18: near "int": syntax error
Error: near line 20: near "/": syntax error
Error: near line 24: unrecognized token: "}"
Error: near line 28: unrecognized token: "}"