Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- void writeToFile() {
- FILE *f = fopen("matrica.txt", "w");
- char c;
- while((c = getchar()) != '#') {
- fputc(c, f);
- }
- fclose(f);
- }
- void printFile() {
- FILE *f=fopen("izlez.txt","r");
- char line[100];
- while(!feof(f)){
- fgets(line,100,f);
- if (feof(f))
- break;
- printf("%s",line);
- }
- fclose(f);
- }
- int main() {
- writeToFile();
- //Vasiot kod tuka
- FILE *f=fopen("matrica.txt","r");
- FILE *f1=fopen("izlez.txt","w");
- int brojRedici = 0, brojKoloni = 0;
- int matrica[100][100];
- fscanf(f, "%d %d", &brojRedici, &brojKoloni);
- int i, j;
- for(i=0; i<brojRedici; i++){
- for(j=0; j<brojKoloni; j++){
- fscanf(f, "%d", &matrica[i][j]);
- }
- }
- for(i=0; i<brojRedici; i++){
- int zbirRedica = 0;
- for(j=0; j<brojKoloni; j++){
- zbirRedica += matrica[i][j];
- }
- if(zbirRedica > 10){
- fprintf(f1, "%d\n", zbirRedica);
- }
- }
- fclose(f);
- fclose(f1);
- printFile();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement