fork download
  1. #include <stdio.h>
  2.  
  3. #define N 160 // データ数(必要に応じて変える)
  4.  
  5. int main() {
  6. // 10Hz.txtから取り込んだデータ(例:ここでは一部)
  7. float time[N] = {
  8. 0.000000,0.100000,0.200000,0.300000,0.400000,0.500000,0.600000,0.700000,0.800000,0.900000,
  9. 1.000000,1.100000,1.200000,1.300000,1.400000,1.500000,1.600000,1.700000,1.800000,1.900000,
  10. // ... 以下略:全部のデータをここに入れていく
  11. };
  12.  
  13. float voltage[N] = {
  14. 3.030531,3.033075,3.017808,3.030531,3.030531,3.030531,3.022897,3.027986,3.017808,3.022897,
  15. 3.027986,3.022897,3.017808,3.022897,3.027986,3.017808,3.030531,3.015264,3.025442,3.015264,
  16. // ... 以下略:全部のデータをここに入れていく
  17. };
  18.  
  19. int peak_count = 0;
  20.  
  21. printf("No.\t時刻[秒]\t電位[V]\n");
  22.  
  23. for (int i = 1; i < N - 1; i++) {
  24. // 電位が上がって下がる瞬間をピークと判断
  25. if (voltage[i] > voltage[i - 1] && voltage[i] > voltage[i + 1]) {
  26. printf("%2d\t%6.2f\t%7.3f\n", ++peak_count, time[i], voltage[i]);
  27. }
  28. }
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 5300KB
stdin
Standard input is empty
stdout
No.	時刻[秒]	電位[V]
 1	  0.10	  3.033
 2	  0.70	  3.028
 3	  1.00	  3.028
 4	  1.40	  3.028
 5	  1.60	  3.031
 6	  1.80	  3.025