1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

C programming

Discussion in 'C' started by jampampinsh, May 27, 2008.

  1. jampampinsh

    jampampinsh New Member

    Joined:
    May 27, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hi there:) maybe it will sound a little bit stupid but i have one easy programming work but its now is too hard for my knowledges.... so maybe someone could help me? i must do a programme where its user writes a text less then 200 words and this programme must count all symbols which appeares more than twice.... so but problem is that the programme shows every symbol more than once which is repeating.... i think that there is something wrong with strcmp;) so i willl write here an programme to;)

    example:

    i write text in programme:
    aaaa bb ccc
    this programme calculate this->
    4 a
    4 a
    4 a
    4 a
    2
    2 b
    2 b
    2
    3 c
    3 c
    3 c

    but it need to bee->
    4 a
    2
    2 b
    3 c






    here is my programme
    Code:
    #include <stdio.h>
    #include <conio.h>
    #include <string.h>
    #define size 200
    
      void main()
      { char text[size],
      mas[100][size];
      int garums;
      int a,b,c,d,e,f,g,h,label,skaits;
      clrscr();
    
      do
      {
      printf("\n Ievadiet tekstu liidz 200 simboliem \n");
      gets(text);
      garums=strlen(text);
    	if(garums>200)
    	printf("teksts par garu, ievadiet citu");
    	if(garums<=0)
    	printf("teksts par iisu, ievadiet citu");
      }
      while(garums>200 || garums<=0);
    
      b=0;
      c=0;
    
      for (a=0; a<garums; a++)
      {
      mas[b][c]=text[a];
    
      c=c+1;
        mas[b][c]='\0';
        b=b+1;
        c=0; }
      mas[b][c]='\0';
    
      skaits=0;
       d=0;
       e=0;
    
      for(e=0;e<b;e++)
         {
    	for(d=0;d<b+1;d++)
    
    
    		{
    			 if(strcmp(mas[e],mas[d])==0)
    			 { skaits=skaits++;
    			 }
    
    
    		}
    
    	if(skaits>=2)
    
    
          printf("\n %d %s",skaits, mas[e]);
          skaits=0;
    
         }
    
    getch();
    
    }
     
    Last edited by a moderator: May 27, 2008

Share This Page