fork download
  1. #include <stdio.h>
  2. #include <stdbool.h>
  3.  
  4. int main(void) {
  5. int n;
  6. scanf("%d",&n);
  7. for(int i=0;i<n;i++){
  8. int a[5];
  9. for(int j=0;j<4;j++)
  10. scanf("%d",&a[j]);
  11. bool samegap=(a[3]-a[2]==a[2]-a[1]);
  12. if(samegap==1){
  13. int d=a[3]-a[2];
  14. a[4]=a[3]+d;
  15. for(int j=0;j<5;j++)
  16. printf("%d ",a[j]);
  17. }
  18. else{
  19. int r=a[3]/a[2];
  20. a[4]=a[3]*r;
  21. for(int j=0;j<5;j++)
  22. printf("%d ",a[j]);
  23. }
  24. printf("\n");
  25. }
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 5292KB
stdin
2
1 2 3 4
1 2 4 8
stdout
1 2 3 4 5 
1 2 4 8 16