fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int n;
  5. printf("データの個数を入力してください: ");
  6. scanf("%d", &n);
  7.  
  8. double time[n], voltage[n], maxVoltage = 0, maxTime = 0;
  9. int maxIndex = 0;
  10.  
  11. printf("時間と電位の値を入力してください:\n");
  12. for(int i = 0; i < n; i++) {
  13. scanf("%lf,%lf", &time[i], &voltage[i]);
  14. }
  15.  
  16. int count = 0;
  17.  
  18. for(int i = 0; i < n; i++) {
  19. if(maxVoltage < voltage[i]) {
  20. maxVoltage = voltage[i];
  21. maxTime = time[i];
  22. maxIndex = i;
  23. count = 0;
  24. }else{
  25. count++;
  26. if(count == 5){
  27. printf("時間: %.2lf秒, 電位の最大値: %.2lfV\n", maxTime, maxVoltage);
  28. maxVoltage = 0;
  29. maxTime = 0;
  30. maxIndex = 0;
  31. }
  32. }
  33. }
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
データの個数を入力してください: 時間と電位の値を入力してください: