Advertisement
BorjanCrvenkov

Code datoteka so brojki C

Feb 2nd, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define MAX 100
  4.  
  5. //ne menuvaj!
  6. void wtf() {
  7. FILE *f = fopen("broevi.txt", "w");
  8. char c;
  9. while((c = getchar()) != EOF) {
  10. fputc(c, f);
  11. }
  12. fclose(f);
  13. }
  14.  
  15. int main()
  16. {
  17. wtf();
  18.  
  19. // vashiot kod ovde
  20. FILE *a=fopen("broevi.txt","r");
  21. int maxbroj,broj;
  22. int n,max=0;
  23. while(1){
  24. fscanf(a,"%d",&n);
  25. if(n==0){
  26. break;
  27. }
  28. for(int i=0;i<n;i++){
  29. fscanf(a,"%d",&broj);
  30. int temp=broj;
  31. while(temp>=10){
  32. temp/=10;
  33. }
  34. if(temp>max){
  35. max=temp;
  36. maxbroj=broj;
  37. }
  38. }
  39. printf("%d\n",maxbroj);
  40. max=0;
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement