Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- int main()
- {
- FILE *p = fopen("in.txt", "r");
- char niza[101];
- char najdolga_niza[101];
- while(fgets(niza, 100, p) != NULL) {
- int n = strlen(niza); // dolzina na nizata
- int broj_na_cifri = 0;
- for(int i = 0; i < n; i++) {
- if(isdigit(niza[i])) { // proveruva dali e cifra
- broj_na_cifri += 1; // dodadi cifra
- }
- }
- if(broj_na_cifri >= 2) {
- if(strlen(najdolga_niza) < strlen(niza)) {
- strcpy(najdolga_niza, niza); // string copy, kopiraj edna niza vo druga
- }
- }
- }
- printf("%s", najdolga_niza);
- return 0;
- }
- // o|abbbbaaaazaab|i
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement