Advertisement
cristobal212

crear programa numerico con este

Sep 5th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. FILE* programa;
  5.  
  6. int main()
  7. {
  8.     char prog[]="\\programa.c";
  9.     int n1=0,n2,c=0;
  10.     scanf("%i",&n2);
  11.     if (n2<0)
  12.         n2=-n2;
  13.     programa=fopen(prog,"wt");
  14.     fclose(programa);
  15.     programa=fopen(prog,"at");
  16.     fprintf(programa,"#include <stdio.h>\n");
  17.     fprintf(programa,"int main ()\n");
  18.     fprintf(programa,"{\n\t");
  19.     while (n1!=n2)
  20.     {
  21.         fprintf(programa,"printf(\"%i\\t\");\n\t",n1);
  22.         n1=n1+1;
  23.         c=c+1;
  24.         if (c==5)
  25.         {
  26.             c=0;
  27.             fprintf(programa,"printf(\"\\n\");\n\t");
  28.         }
  29.     }
  30.     fprintf(programa,"return 0;}");
  31.     fclose(programa);
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement