Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4. // ne menuvaj ovde
  5. void wtf() {
  6. FILE *f = fopen("dat.txt", "w");
  7. char c;
  8. while((c = getchar()) != EOF) {
  9. fputc(c, f);
  10. }
  11. fclose(f);
  12. }
  13.  
  14. int main() {
  15. wtf();
  16. // vasiot kod ovde
  17. char red[101],maxred[101];
  18. int i,prva,posledna,maxprva,maxposledna,max=-1;
  19.  
  20. FILE *vlez;
  21. vlez=fopen("dat.txt","r");
  22. if(vlez==NULL) {
  23. printf("Greska");
  24. return -1;
  25. }
  26.  
  27.  
  28. while(fgets(red,100,vlez)!=NULL) {
  29.  
  30. for(i=0; i<strlen(red); i++)
  31. if(isdigit(red[i])) {
  32. prva=i;
  33. break;
  34. }
  35.  
  36. for(i=0; i<strlen(red); i++)
  37. if(isdigit(red[i]))
  38. posledna=i;
  39.  
  40.  
  41. if(posledna-prva>=max) {
  42. max=posledna-prva;
  43. strcpy(maxred,red);
  44. maxprva=prva;
  45. maxposledna=posledna;
  46. }
  47.  
  48. }
  49.  
  50. for(i=maxprva; i<=maxposledna; i++)
  51. printf("%c",maxred[i]);
  52.  
  53.  
  54.  
  55.  
  56. fclose(vlez);
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement