fork(1) download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4.  
  5. int main() {
  6. char t[10];
  7. char r[10];
  8. fgets(t, 10, stdin);
  9. int c = 0;
  10. for (int i = 0; i < 10 && t[i] != 0; i++) {
  11. if (isdigit(t[i]) || t[i] == 'i' || t[i] == 'p' || t[i] == '+' ||
  12. t[i] == '-' || t[i] == '*' || t[i] == '/' || t[i] == '^') {
  13. r[c++] = t[i];
  14. }
  15. }
  16. r[c] = '\0';
  17. printf("%s", r);
  18. }
  19.  
Success #stdin #stdout 0s 2172KB
stdin
3 5+2ia
stdout
35+2i