list.c

来自「Sherwood算法消除最坏实例」· C语言 代码 · 共 34 行

C
34
字号
#include<stdio.h>
#include<stdlib.h>

/****** create a descending sequence of n integers ******/
main(int argc, char *argv[])
{
   int n, i, *list;
   FILE *outfp;

   if(argc == 3)
   {
      if( (outfp = fopen(argv[1], "w")) == NULL)
      {
         printf("Can't open the file!\n");
         exit(2);
      }
   }
   else
   {
      printf("Usage: %s outfile n \nNote: outfile is to store the n integer created\n", argv[0]);
      exit(1);
   }

   n = atoi(argv[2]);

   for(i = 0; i < n; i++)
      fprintf(outfp, "%d ", n - i);
   fclose(outfp);
   free(list);
   return 0;
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?