Advertisement
masterm1nd99

Букви помеѓу првите две цифри во стринг Problem 2 (1 / 3)

Dec 25th, 2018
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3.  
  4. int main()
  5. {
  6. char c[100];
  7. int i=0,j=0;
  8. char l;
  9. while((l=getchar())!='\n')
  10. {
  11. *(c+i)=l;
  12. i++;
  13. }
  14. *(c+i)='\0';
  15.  
  16. for(i=0;*(c+i)!='\0';i++)
  17. {
  18. if(isdigit(*(c+i)))
  19. {
  20. *(c+j)=*(c+i);
  21. i++;j++;
  22. while(!isdigit(*(c+i))&&*(c+i)!='\0')
  23. {
  24. *(c+j)=*(c+i);
  25. i++;
  26. j++;
  27. }
  28. *(c+j)=*(c+i);
  29. *(c+j+1)='\0';
  30. break;
  31. }
  32. }
  33. if(j==0)
  34. {
  35. printf("Nema cifri");
  36. }
  37. else
  38. {
  39. printf("%s",c);
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement