fork download
  1. #include <stdio.h>
  2.  
  3. int main(int argc, const char * argv[]) {
  4. // init & input
  5. char c;
  6. int a[2];
  7. int cnt;
  8. printf("input times\n");
  9. scanf("%d", &cnt);
  10. int ans[cnt];
  11. int space, temp, flag;
  12.  
  13. for (int i=0; i<cnt; i++) {
  14. space=0; temp=0; flag=0;
  15. printf("input number1 number2\n");
  16. while((c=getchar())!='\n') {
  17. if (c==' ') {
  18. a[space] = temp ;
  19. space++;
  20. temp = 0 ;
  21. flag = 0 ;
  22. }
  23. else {
  24. flag = 1 ;
  25. temp = temp * 10 + (c-48);
  26. }
  27. }
  28. if(flag)
  29. a[space] = temp;
  30.  
  31. ans[i] = a[0] + a[1];
  32. }
  33. // output answer
  34. for (int i=0; i<cnt; i++) {
  35. printf("%d ", ans[i]);
  36. }
  37. }
  38.  
Time limit exceeded #stdin #stdout 5s 4292KB
stdin
Standard input is empty
stdout
Standard output is empty