• 字符输入输出


     /************************************/

    /*文件复制*/
    #include <stdio.h>
    main()
    {
     int c;
     c = getchar();
     while(c != EOF)
     {
      putchar(c);
      c = getchar();
     }
    }
     
    /*********************************/
    /*字符计数*/
    #include <stdio.h>
    main()
    {
     double nc;
     for(nc=0;getchar()!=EOF;++nc)
      ;
     printf("%.0f ",nc);
    }
     
    /***********************************/
    /*行计数*/
    #include <stdio.h>
    main()
    {
     int c,n1;
     n1 = 0;
     while((c=getchar())!= EOF)
      if(c == ' ')
       ++n1;
     printf("%d ",n1); 
    }
     
    /*****************************************/
    /*单词计数*/
    #include <stdio.h>
    #define IN 1 /*在单词内*/
    #define OUT 0 /*在单词外*/
    /*统计输入的nl行数、nc单词数与nw字符数*/
    main()
    {
     int c,n1,nw,nc,state;
     state = OUT;
     n1 = nw =nc = 0;
     while((c = getchar()) != EOF)
     {
      ++nc;
      if(c == ' ')
       ++n1;
      if(c == ' ' ||c = ' ' c == ' ')
       state = OUT;
      else if (STATE == OUT)
      {
       state = IN;
       ++nw;
      }
     }
     printf("%d %d %d ",n1,nw,nc);
    }
     
     
     
     
     
     
     
     
     
  • 相关阅读:
    Rocket
    Rocket
    Rocket
    Rocket
    POJ 1849 树的直径 Two
    SGU 495 Kids and Prizes
    HDU 4336 概率DP 状压
    HDU 4089 && UVa 1498 Activation 带环的概率DP
    SGU 149 树形DP Computer Network
    暑假集训刷题记录
  • 原文地址:https://www.cnblogs.com/TheFly/p/11813929.html
Copyright © 2020-2023  润新知