Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- // DO NOT CHANGE HERE
- void wtf() {
- FILE *f = fopen("datnum.txt", "w");
- char c;
- while((c = getchar()) != EOF) {
- fputc(c, f);
- }
- fclose(f);
- }
- int main() {
- wtf();
- // your code here
- FILE *f = fopen("datnum.txt", "r");
- char c;
- char cc[100];
- int countDigit = 0;
- int countLetter = 0;
- int max = 0;
- int ratio = 0;
- char result[100];
- while((c = fgetc(f)) != EOF)
- {
- while((c = fgetc(f)) != '\n')
- {
- if(isdigit(c))
- {
- countDigit++;
- }
- if(isalpha(c))
- {
- countLetter++;
- }
- ratio = countDigit / countLetter;
- if(ratio > max)
- {
- max = ratio;
- fgets(cc, 100, f);
- //strcpy(result, cc);
- }
- }
- countDigit = 0;
- countLetter = 0;
- ratio = 0;
- }
- printf("%s", cc);
- fclose(f);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement