WikiStart: dat.txt

File dat.txt, 18.0 KB (added by 152071, 6 years ago)
Line 
1najdolg zbor
2#include <stdio.h>
3#include <stdlib.h>
4
5int main()
6{
7 FILE* dat=fopen("C:/Users/Neno/Desktop/text.txt", "r");
8
9 if(dat==NULL)
10 {
11 return 0;
12 }
13
14 char red[80],maxred[80];
15 int i,maxzbor=-9999,bukva,max=-9999,br_red,brojac=0;
16
17
18 while(fgets(red,80,dat)!=NULL)
19 {
20 bukva=0;
21 max=-9999;
22 for(i=0;i<strlen(red);i++)
23 {
24
25 if(isalpha(red[i]))
26 {
27 bukva++;
28 }
29 else
30 {
31 bukva=0;
32 }
33
34 if(max<bukva)
35 {
36 max=bukva;
37 }
38 }
39
40 if(maxzbor<max)
41 {
42 maxzbor=max;
43 br_red=brojac;
44 for(i=0;i<80;i++)
45 {
46 maxred[i] = red[i];
47 }
48 }
49 brojac++;
50
51 }
52
53 printf("%s",maxred);
54 printf("%d",br_red);
55 fclose(dat);
56 return 0;
57}
58red so najdolg zbor
59#include <stdio.h>
60#include <stdlib.h>
61
62int main()
63{
64 FILE* dat=fopen("C:/Users/Neno/Desktop/text.txt", "r");
65
66 char red[80],kraen_red[80];
67 int i,povtoruvanje=0,max=-9999,max_povt=-9999;
68
69 if(dat==NULL)
70 {
71 return 0;
72 }
73
74 while(fgets(red,80,dat)!=NULL)
75 {
76 povtoruvanje = 0;
77 max=-9999;
78 for(i=0;i<strlen(red);i++)
79 {
80
81 if(isalpha(red[i]))
82 {
83 povtoruvanje++;
84 }
85
86 else
87 {
88 povtoruvanje=0;
89 }
90 if(max<povtoruvanje)
91 {
92 max=povtoruvanje;
93 }
94
95 }
96
97 if(max_povt<max)
98 {
99 max_povt = max;
100
101 for(i=0;i<80;i++)
102 {
103 kraen_red[i] = red[i];
104 }
105 }
106
107
108 }
109
110 printf("%d\n", max_povt);
111 printf("%s\n",kraen_red);
112
113
114 fclose(dat);
115 return 0;
116}
117odnos golemi mali bukvi
118#include <stdio.h>
119#include <stdlib.h>
120
121int main()
122{
123 FILE* dat=fopen("C:/Users/Neno/Desktop/text.txt","r");
124
125 if(dat==NULL)
126 {
127 return 0;
128 }
129
130 char red[80];
131 int i,brojac=0,max_red;
132 float mali,golemi,odnos,max=-9999;
133
134 while(fgets(red,80,dat)!=NULL)
135 {
136 mali=0;
137 golemi=0;
138
139 for(i=0;i<strlen(red);i++)
140 {
141 if(isalpha(red[i])&&isupper(red[i]))
142 {
143 golemi++;
144 }
145
146 if(isalpha(red[i]) && islower(red[i]))
147 {
148 mali++;
149 }
150 }
151 odnos=golemi/mali;
152
153 if(max<odnos)
154 {
155 max=odnos;
156 max_red=brojac;
157 }
158
159 printf("%.2f %s",odnos,red);
160
161 brojac++;
162
163 }
164 printf("\n");
165 printf("%d",max_red);
166
167 fclose(dat);
168 return 0;
169}
170odnos prazno mesto bukvi
171#include <stdio.h>
172#include <stdlib.h>
173
174int main()
175{
176 FILE* dat=fopen("C:/Users/Neno/Desktop/text.txt", "r");
177
178 if(dat==NULL)
179 {
180 return 0;
181 }
182// MI PRINTA PLUS EDNO PRAZNO MESTO !!
183
184 char red[80];
185 int i,brojac=0,max=-9999,min_red;
186 float odnos,pr_mesto=0,bukvi=0;
187
188 while(fgets(red,80,dat)!=NULL)
189 {
190 pr_mesto=0;
191 bukvi=0;
192
193 for(i=0;i<strlen(red);i++)
194 {
195 if(isalpha(red[i]))
196 {
197 bukvi++;
198 } else if(isspace(red[i]))
199 {
200 pr_mesto++;
201 }
202
203 }
204
205 pr_mesto -= 1;
206
207 printf("%.2f %.2f\n",pr_mesto,bukvi);
208 odnos=pr_mesto/bukvi;
209
210 if(max<odnos)
211 {
212 max=odnos;
213 min_red=brojac;
214 }
215
216 printf("%.2f %s",odnos,red);
217 brojac++;
218 }
219
220 printf("%d\n",min_red);
221 fclose(dat);
222 return 0;
223}
224zborovi podologi od 5 bukvi
225#include <stdio.h>
226#include <stdlib.h>
227
228int main()
229{
230 FILE* dat1=fopen("C:/Users/Neno/Desktop/text.txt","r");
231
232 if(dat1==NULL)
233 {
234 return 0;
235 }
236
237 char zbor[16];
238 int dolzina,i,broj_zborovi=0,tochnost=0;
239
240 while(fscanf(dat1,"%s",&zbor)==1)
241 {
242 dolzina = strlen(zbor);
243 tochnost=0;
244
245 if(dolzina > 5 && dolzina%2!=0)
246 {
247 for(i=0;i<dolzina;i++)
248 {
249 zbor[i]=tolower(zbor[i]);
250
251 if((zbor[0]=='a' || zbor[0]=='e' || zbor[0]=='i' || zbor[0]=='o' || zbor[0]=='u') && (zbor[dolzina-1]!='a' && zbor[dolzina-1]!='e' && zbor[dolzina-1]!='i' && zbor[dolzina-1]!='o' && zbor[dolzina-1]!='u'))
252 {
253 tochnost=1;
254 }
255 else
256 {
257 tochnost=0;
258 }
259
260 }
261
262
263 }
264
265 if(tochnost==1)
266 {
267 printf("%s\n",zbor);
268 broj_zborovi++;
269 }
270
271 }
272
273 printf("%d\n",broj_zborovi);
274
275 fclose(dat1);
276 return 0;
277}
278
279datoteka
280#include <stdio.h>
281#include <stdlib.h>
282
283int main()
284{
285 FILE* dat=fopen("C:/Users/Neno/Desktop/text.txt", "r");
286
287
288 if(dat==NULL)
289 {
290 return 0;
291 }
292
293
294 char red[101],c;
295 int i,j,zborovi=0,zborovi_vo_red=0,znamence;
296
297 fscanf(dat,"%c\n",&c);
298
299 while(fgets(red,101,dat)!=NULL)
300 {
301
302 znamence=-1;
303
304 for(i=0;i<strlen(red);i++)
305 {
306 if(znamence==-1&&isalnum(red[i]))
307 {
308 znamence=i;
309 }
310
311 else if (znamence!=-1 && !(isalnum(red[i])))
312 {
313 if(red[znamence]==c && red[i-1]!=c)
314 {
315 int j;
316 for(j=znamence;j<i;j++)
317 {
318 printf("%c",red[j]);
319 }
320 zborovi++;
321 zborovi_vo_red++;
322 printf(" ");
323 }
324 znamence=-1;
325 }
326 }
327
328 if(zborovi_vo_red > 0)
329 {
330 printf("\n");
331 }
332 }
333 printf("%d",zborovi);
334
335 fclose(dat);
336 return 0;
337}
338zborovi so brojki
339#include <stdio.h>
340#include <stdlib.h>
341
342int main()
343{
344 FILE* dat=fopen("C:/Users/Neno/Desktop/text.txt", "r");
345
346 if(dat==NULL)
347 {
348 return 0;
349 }
350
351 char red[101],c;
352
353 fscanf(dat,"%c\n",&c);
354 int znamence,i,j,zborovi=0,zborovi_vo_red=0;
355
356 while(fgets(red,101,dat)!=NULL)
357 {
358
359 znamence=-1;
360 zborovi_vo_red=0;
361 for(i=0;i<strlen(red);i++)
362 {
363
364
365 if(znamence==-1 && isalnum(red[i]) )
366 {
367 znamence=i;
368 }
369
370 else if(znamence!=-1 && !(isalnum(red[i])))
371 {
372 if(red[znamence]==c && red[i-1]==c)
373 {
374 int j;
375 for(j=znamence;j<i;j++)
376 {
377 printf("%c",red[j]);
378 }
379 zborovi++;
380 zborovi_vo_red++;
381 printf(" ");
382 }
383
384 znamence=-1;
385
386 }
387
388
389
390
391 }
392
393 if(zborovi_vo_red > 0)
394 {
395 printf("\n");
396 }
397
398 }
399
400 printf("%d",zborovi);
401
402 fclose(dat);
403 return 0;
404}
405najdi zborovi 1 daT.
406#include<stdio.h>
407#include<string.h>
408#include<ctype.h>
409// ne menuvaj ovde
410void wtf() {
411 FILE *f = fopen("log.txt", "w");
412 char c;
413 while((c = getchar()) != EOF) {
414 fputc(c, f);
415 }
416 fclose(f);
417}
418int funk(char *red){
419 int i,dolzina,flag=0,flag1=0,flag2=0,brdigit=0,bralpha=0;
420 dolzina=strlen(red);
421 for(i=0;i<dolzina;i++){
422 if(isdigit(red[i])){
423 brdigit++;
424 }
425 if(isalpha(red[0])&&isalpha(red[1])&&isalpha(red[2])&&isalpha(red[3])==0)
426 flag2=1;
427 if(isdigit(red[0])&&isdigit(red[1])&&isdigit(red[2])&&isdigit(red[3])){
428 if(isalpha(red[i]))
429 bralpha++;
430 }
431 }
432 if(brdigit==dolzina-1)
433 flag=1;
434 if(dolzina-5==isalpha)
435 flag2=1;
436 if(flag==1||flag1==1||flag2==1)
437 return 1;
438 else
439 return 0;
440}
441
442int main() {
443 wtf();
444 // vasiot kod ovde
445 FILE *f=fopen("log.txt","r");
446 int suma=0,br=0;
447 char red[25],pecati[25];
448 while(fgets(red,25,f)){
449 suma+=funk(red);
450 }
451 printf("%d",suma);
452 fclose(f);
453 return 0;
454}
455#include <stdio.h>
456#define MAX 100
457//Vasiot indeks zapisete go kako vrednost na outName
458const char outName[] = "152071.txt";
459
460
461void printFile() {
462 FILE *f=fopen(outName, "r");
463 char c;
464 while((c = fgetc(f)) != EOF) {
465 putchar(c);
466 }
467 fclose(f);
468}
469
470
471void writeToFile() {
472 FILE *f = fopen("matricaIn.txt", "w");
473 char c;
474 while((c = getchar()) != EOF) {
475 fputc(c, f);
476 }
477 fclose(f);
478}
479
480
481int main() {
482
483 writeToFile();
484 // Vasiot kod pocnuva od tuka
485 int n,i,j;
486 int a[MAX][MAX],b[MAX][MAX];
487 FILE *f,*f1;
488 f=fopen("matricaIn.txt","r");
489 if(!feof(f))
490 fscanf(f,"%d",&n);
491 for(i=0;i<n;i++){
492 for(j=0;j<n;j++){
493 fscanf(f,"%d",&a[i][j]);
494
495 }
496 }
497 fclose(f);
498 for(i=0;i<n;i++){
499 for(j=0;j<n;j++){
500 b[j][i]=a[n-1-i][n-1-j];
501 }
502 }
503 f1=fopen(outName,"w");
504 //fprintf(f1,"%d %d\n",i,j);
505 for(i=0;i<n;i++){
506 for(j=0;j<n;j++){
507 fprintf(f1,"%d ",b[i][j]);}fprintf(f1,"\n");}
508 fclose(f1);
509 // do tuka
510 printFile();
511 return 0;
512}
513
514dve datoteki
515#include <stdio.h>
516#include <stdlib.h>
517
518int ocena (broj)
519{
520 if(broj<=50)
521 {
522 return 5;
523 }
524
525 if(broj<=60)
526 {
527 return 6;
528 }
529
530 if(broj<=70)
531 {
532 return 7;
533 }
534
535 if(broj<=80)
536 {
537 return 8;
538 }
539
540 if(broj<=90)
541 {
542 return 9;
543 }
544
545 if(broj<=100)
546 {
547 return 10;
548 }
549}
550
551int main()
552{
553 FILE* dat1=fopen("C:/Users/Neno/Desktop/Rezultati_Kolokviumi.txt", "r");
554 FILE* dat2=fopen("C:/Users/Neno/Desktop/Konecni_Rezultati.txt", "w");
555
556 if(dat1==NULL)
557 {
558 return 0;
559 }
560
561 if(dat2==NULL)
562 {
563 return 0;
564 }
565 int index_prv_najdobar=0;
566 int index_vtor_najdobar=0;
567 int poeni_prv_najdobar=0;
568 int poeni_vtor_najdobar=0;
569
570 while(!feof(dat1))
571 {
572 long index;
573 int prv_kol,vtor_kol;
574
575
576
577 fscanf(dat1,"%d %d %d",&index,&prv_kol,&vtor_kol);
578 printf("%ld %d %d\n",index,prv_kol,vtor_kol);
579
580 if(poeni_prv_najdobar < prv_kol + vtor_kol)
581 {
582 poeni_prv_najdobar = prv_kol + vtor_kol;
583 index_prv_najdobar = index;
584 }
585
586 else if(poeni_vtor_najdobar < prv_kol + vtor_kol)
587 {
588 poeni_vtor_najdobar = prv_kol + vtor_kol;
589 index_vtor_najdobar = index;
590 }
591 }
592
593 fprintf(dat2,"Najdobrite dvajca studenti se:\n");
594 fprintf(dat2,"%d %d %d\n", index_prv_najdobar,poeni_prv_najdobar,ocena(poeni_prv_najdobar));
595 fprintf(dat2,"%d %d %d\n", index_vtor_najdobar,poeni_vtor_najdobar,ocena(poeni_vtor_najdobar));
596
597 fclose(dat1);
598 fclose(dat2);
599
600 return 0;
601}
602br. zborovi plindromi dat.
603#include <stdio.h>
604#include <stdlib.h>
605
606int main()
607{
608 FILE* dat1=fopen("C:/Users/Neno/Desktop/text.txt", "r");
609 if(dat1==NULL)
610 {
611 return 0;
612 }
613
614 char zbor[11],obraten[11];
615 int i,dolzina,palindromi=0;
616
617 while(fscanf(dat1,"%s",&zbor)==1)
618 {
619 dolzina=strlen(zbor);
620
621 for(i=0;i<dolzina;i++)
622 {
623 zbor[i]=tolower(zbor[i]);
624
625 obraten[i]=zbor[dolzina-i-1];
626
627 }
628
629 obraten[dolzina]='\0';
630
631 if(strcmp(zbor,obraten)==0)
632 {
633 palindromi++;
634 printf("%s\n",obraten);
635 }
636 }
637 printf("%d\n",palindromi);
638
639 fclose(dat1);
640 return 0;
641}
642pochetna ne zavrshna bukva
643#include <stdio.h>
644#include <stdlib.h>
645
646
647int main()
648{
649 FILE* f = fopen("C:/Users/Neno/Desktop/text.txt", "r");
650
651 char c, red[101];
652
653 fscanf(f, "%c\n", &c);
654
655 int zborovi = 0;
656
657 while (fgets(red, 80, f) != NULL) {
658 int zborovi_vo_redot = 0;
659
660 int znamence = -1; // ZNACHI = indeksot na pocetokot na zborot
661
662 int i;
663
664 for (i = 0; i < strlen(red); i++) {
665
666 if (znamence == -1&&isalnum(red[i])) {
667 znamence = i;
668 } else if (znamence != -1 && !isalnum(red[i])) {
669
670 if (red[znamence] == c && red[i - 1] != c) {
671 zborovi++;
672 zborovi_vo_redot++;
673
674 int j;
675
676 for (j = znamence; j < i; j++) {
677 printf("%c", red[j]);
678 }
679
680 printf(" ");
681 }
682
683 znamence = -1;
684 }
685
686 }
687
688 if (zborovi_vo_redot > 0) {
689 printf("\n");
690 }
691 }
692
693 printf("%d\n", zborovi);
694
695 fclose(f);
696
697 return 0;
698}
699pojavuvanje na site golemi bukvi
700#include <stdio.h>
701#include <stdlib.h>
702
703int main()
704{
705 FILE* dat1=fopen("C:/Users/Neno/Desktop/text.txt","r");
706 FILE* dat2=fopen("C:/Users/Neno/Desktop/text2.txt","w");
707
708
709 if(dat1==NULL)
710 {
711 return 0;
712 }
713
714 if(dat2==NULL)
715 {
716 return 0;
717 }
718
719 float golemi,redovi=0,sumagolemi=0;
720 int i;
721 char red[80];
722 while(fgets(red,80,dat1)!=NULL)
723 {
724 golemi=0;
725
726 for(i=0;i<strlen(red);i++)
727 {
728 if(isalpha(red[i]))
729 {
730 if(isupper(red[i]))
731 {
732 golemi++;
733 }
734 }
735 }
736 redovi++;
737 sumagolemi+=golemi;
738 fprintf(dat2,"%.2f\n",golemi);
739 }
740 float prosechen_broj;
741 prosechen_broj=sumagolemi/redovi;
742 fprintf(dat2,"%.2f\n",prosechen_broj);
743
744 fclose(dat1);
745 fclose(dat2);
746 return 0;
747}
748shifriranje
749#include <stdio.h>
750#include <stdlib.h>
751
752int main()
753{
754 FILE* sifra = fopen("C:/Users/Neno/Desktop/sifra.txt", "r");
755
756 if (sifra == NULL) {
757 printf("ZAEBANO E SVE. GAS GAS. -- SEVE :P PUSA BOK.\n");
758 return 1;
759 }
760
761 char c = fgetc(sifra);
762
763 while (c != EOF) {
764
765 if (isalpha(c)) {
766 c = tolower(c);
767
768 if (c >= 'x') {
769 c = 'a' + (c - 'x');
770 } else {
771 c = c + 3;
772 }
773
774 printf("%c", c);
775 } else {
776 printf("%c", c);
777 }
778
779 c = fgetc(sifra);
780 }
781
782 fclose(sifra);
783
784 return 0;
785}
786#include <stdio.h>
787#include <stdlib.h>
788
789int main()
790{
791 FILE* sifra=fopen("C:/Users/Neno/Desktop/sifra.txt","r");
792
793 if(sifra==NULL)
794 {
795 return 0;
796 }
797
798 char c = fgetc(sifra);
799
800 while(c!=EOF)
801 {
802 if(isalpha(c) && isupper(c))
803 {
804 if(c>='N')
805 {
806 c='A'+(c-'N');
807 }
808
809 else
810 {
811 c=c+13;
812 }
813
814 c = tolower(c);
815 }
816
817 else if (isalpha(c) && islower(c))
818 {
819 if(c<='g')
820 {
821 c='z' - ('g' - c);
822 }
823
824 else
825 {
826 c-=7;
827 }
828 c=toupper(c);
829 }
830
831 else
832 {
833 c='-';
834 }
835
836 printf("%c",c);
837
838 c=fgetc(sifra);
839 }
840
841
842 fclose(sifra);
843
844 return 0;
845}
846#include <stdio.h>
847#include <stdlib.h>
848
849int main()
850{
851 FILE* dat=fopen("C:/Users/Neno/Desktop/text.txt", "r");
852
853 int i;
854 char red[80];
855 int suma;
856
857 if(dat==NULL)
858 {
859 return 0;
860 }
861
862 while(fgets(red,81,dat)!=NULL)
863 {
864 for(i=0;i<strlen(red);i++)
865 {
866 char c = red[i];
867
868 if(isalpha(c))
869 {
870 if(islower(c))
871 {
872 c='a'+(c+strlen(red)%26)%26;
873 }
874 }
875
876 printf("%c",c);
877 }
878
879
880
881 }
882
883
884 fclose(dat);
885
886 return 0;
887}
888promena na 3 zbor
889#include <stdio.h>
890
891
892#include <stdio.h>
893#include <stdlib.h>
894//13
895int main()
896{
897 FILE* dat=fopen("C:/Users/Neno/Desktop/text.txt", "r");
898
899 if(dat==NULL)
900 {
901 return 0;
902 }
903
904 int brojac = 0,i;
905
906 char zbor[21];
907
908 while (fscanf(dat, "%s", &zbor) == 1) {
909
910 brojac++;
911
912 if (brojac == 3) {
913 for(i=0;i<strlen(zbor);i++)
914 {
915
916 zbor[i]=tolower(zbor[i]);
917 if(zbor[i]=='a')
918 {
919 if(i==0)
920 {
921 zbor[i] = 'A';
922 }
923
924 else
925 {
926 int temp=zbor[i];
927 zbor[i] = zbor[i-1];
928 zbor[i-1] = temp;
929 }
930 }
931
932 }
933 printf("%s\n", zbor);
934
935 brojac = 0;
936 }
937 }
938
939 fclose(dat);
940
941 return 0;
942}
943kompleksnost
944#include <stdio.h>
945#include <stdlib.h>
946
947int main()
948{
949 FILE* dat=fopen("C:/Users/Neno/Desktop/text.txt","r");
950
951 char red[80],kraen_red[80];
952 int i,suma,max=-9999;
953
954 if(dat==NULL)
955 {
956 return 0;
957 }
958
959 while(fgets(red,80,dat)!=NULL)
960 {
961 suma=0;
962
963 for(i=0;i<strlen(red);i++)
964 {
965 if(isalpha(red[i]))
966 {
967 if(islower(red[i]))
968 {
969 suma+=red[i];
970 }
971 }
972 }
973 if(max<suma)
974 {
975 max=suma;
976
977 for(i=0;i<80;i++)
978 {
979 kraen_red[i] = red[i];
980 }
981 }
982 }
983
984 printf("%d\n",max);
985 printf("%s",kraen_red);
986
987 fclose(dat);
988 return 0;
989}