Advertisement
Alx09

Ex 6 Sebi

May 8th, 2020
1,782
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main() {
  5.     unsigned n; // numarul n
  6.     FILE *f; // variabila de tip fiser
  7.     f = fopen("in.txt", "r");// deschidere in mod citire
  8.     fscanf(f, "%u", &n);  // citim numarul
  9.     fclose(f);//inchidem fiserul
  10.     f = fopen("out.txt", "w");// deschidem in mod scriere
  11.     if (n % 2) { // daca n este impar nu avem nici o combinatie posibila
  12.         fprintf(f, "0"); // afisam 0
  13.         return 0; // oprim programul
  14.     }
  15.     fprintf(f, "%u", n / 4); // aceasta este formula mereu va da rezultatul bun
  16.     fclose(f);// inchidem din nou fiser
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement