Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

c³ÌÐòÉè¼ÆÓïÑÔ¹Ù·½Ìâ½â°æ¿±Îó1

#include <stdio.h>
#define MAXHIST 15
#define MAXWORD 11
#define IN  1
#define OUT  0
//´òÓ¡ÊäÈëÖе¥´Ê³¤¶ÈµÄˮƽ·½ÏòÖ±·½Í¼£¬
void main()
{
 int c, i, nc, state;
 int len;     //length of each bar
 int maxvalue;    //maximum value for wl[]
 int ovflow;     //number of overflow words
 int wl[MAXWORD];   //word length count
 
 state = OUT;
 nc = 0;                     //number of chars in a word
 ovflow = 0;
 for (i = 0; i < MAXWORD; ++i)//Êý×é³õʼ»¯
  wl[i] = 0;
 
 
 while((c = getchar()) != EOF){
  if (c == ' ' || c == '\n' || c == '\t'){
   state = OUT;
   if(nc > 0)
    if(nc < MAXWORD)
     ++wl[nc];
    else
     ++ovflow;
   nc = 0;
  }else if (state == OUT){
   state = IN;
   nc = 1;
  }else
   ++nc;
 }
 
  maxvalue = 0;
 for (i = 1; i < MAXWORD; ++i)
  if (wl[i] > maxvalue)
   maxvalue = wl[i];
  
 for (i = 1; i < MAXWORD; ++i){
  printf("%5d - %d : ",i, wl[i]);
  if(wl[i] > 0) {
     if((len * wl[i] * MAXHIST / maxvalue) <= 0)
    len = wl[i];//ÊéÉÏ´Ë´¦±¾À´Îªlen = 1
  }else
   len = 0;
  while (len > 0){
   putchar('*');
   --len;
  }
  putchar('\n');
 }
 if (ovflow > 0)
  printf("There are %d words >= %d\n", ovflow, MAXWORD);
  }


Ïà¹ØÎĵµ£º

¡¶The C Programming Language¡·µÚ¶þ´ÎÔĶÁÖ®ÊÕ»ñ

µÚÒ»Õ µ¼ÑÔ
    1£¬¶¨Òå(define)ÓëÉùÃ÷(declaration) 
    ¶¨Òå±íʾ´´½¨±äÁ¿»ò·ÖÅä´æ´¢µ¥Ôª£»¶øÉùÃ÷Ö¸µÄÊÇ˵Ã÷±äÁ¿µÄÐÔÖÊ£¬µ«²»·ÖÅä´æ´¢µ¥Ôª¡£
µÚ¶þÕ ÀàÐÍ¡¢ÔËËã·ûºÍ±í´ïʽ
    1£¬Êý¾ÝÀàÐͼ°³¤¶È
    CÖÐÖ»ÓÐ4ÖÖ»ù±¾Êý¾ÝÀàÐÍ£ºchar ,int ,float ......

ÉîÈëÀí½âCÓïÑÔÖ¸ÕëµÄ°ÂÃØ¡¾×ªÌû¡¿

http://www.kuqin.com/language/20090314/39862.html
Ö¸ÕëÊÇÒ»¸öÌØÊâµÄ±äÁ¿£¬ËüÀïÃæ´æ´¢µÄÊýÖµ±»½âÊͳÉΪÄÚ´æÀïµÄÒ»¸öµØÖ·¡£ Òª¸ãÇåÒ»¸öÖ¸ÕëÐèÒª¸ãÇåÖ¸ÕëµÄËÄ·½ÃæµÄÄÚÈÝ£ºÖ¸ÕëµÄÀàÐÍ£¬Ö¸ÕëËùÖ¸ÏòµÄ ÀàÐÍ£¬Ö¸ÕëµÄÖµ»òÕß½ÐÖ¸ÕëËùÖ¸ÏòµÄÄÚ´æÇø£¬»¹ÓÐÖ¸Õë±¾ÉíËùÕ¼¾ÝµÄÄÚ´æÇø¡£ÈÃÎÒÃÇ·Ö±ð˵Ã÷¡£
¡¡¡¡ ÏÈÉùÃ÷¼¸¸öÖ¸Õë·Å×Å×öÀý× ......

CÓïÑÔµÄÒ»¸ö¼òµ¥Ëã·¨: 26¸ö×ÖĸËæ»ú²½Éú³É

Ò»¸ö¼òµ¥µÄС³ÌÐò, Ô­ÌâÄ¿¼û<CÓïÑÔ³ÌÐòÉè¼Æ-ÏÖ´ú·½·¨>µÚ°ËÕÂÁ·Ï°13.
ÓÉÓÚ×Ô¼ºÖ»¿´µ½µÚ°ËÕÂ, ËùÒÔ, ²»¸ÒóȻʹÓú¯ÊýµÈÆäËûÄÚÈÝ, ¸ßÊÖÇë·ÅÉù´óЦ.
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#define ROWS 10
#define COLS 10
/**
* @author: selfimpr
* @blog: http:// ......

×ÛºÏÔËÓÃCÓïÑÔÖ¸ÕëÇ¿ÖÆת»»ºÍ»Øµ÷º¯Êý


  
ÔÚÕâ¸öÀý×ÓÀ»Øµ÷º¯Êý±È½ÏÁ½¸öÖµ¡£²éÕÒº¯ÊýÏò±È½Ïº¯Êý´«µÝÁ½¸öÖ¸ÏòÐèÒª½øÐбȽϵÄÖµµÄÖ¸Õ룬²¢¼ì²é±È½Ïº¯ÊýµÄ·µ»ØÖµ¡£ÀýÈ磺Áã±íʾÏàµÈµÄÖµ£¬ÏÖÔÚ²éÕÒº¯
Êý¾ÍÓëÀàÐÍÎ޹أ¬ÒòΪËü±¾Éí²¢²»Ö´ÐÐʵ¼ÊµÄ±È½Ï¡£È·Êµ£¬µ÷ÓÃÕß±ØÐë±àд±ØÐèµÄ±È½Ïº¯Êý£¬µ«ÕâÑù×öÊǺÜÈÝÒ׵ģ¬ÒòΪµ÷ÓÃÕßÖªµÀÁ´±íÖÐËù°üº¬µÄÖµµÄÀàÐÍ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ