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

C Program for Fantastic puzzle and string manipulation.

Discussion in 'C' started by bc.jat11, Sep 26, 2011.

  1. bc.jat11

    bc.jat11 New Member

    Joined:
    Sep 26, 2011
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Deesa,Gujarat,India.
    Home Page:
    See this program by running on your computer it is very fantastic.
    What is...
    This program is take one string( max length of 10 )from user and then it display symbol on alphabet try how it works now.
    Code:
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    
        int i,j,t,b,z,f,counter,len,flag,flag1,flag2,M;
        int total_counter[27],posx[10],posy[10];
        char alphabet[26],string[10];
        TOP:
        counter=0;
        j=0;
        clrscr();
    
        total_counter[0]=0;
        printf("\n Enter string:");
        gets(string);
    
        printf("\n\n\n");
        for(i=65;i<=90;i++)
        {
           if(counter==10)
           {
    	  printf("\n\n\n\n\n");
    	  counter=0;
           }
    
           printf(" %5c",i);
           alphabet[j]=(char)i;
    
           j+=1;
           counter+=1;
           total_counter[j]=total_counter[j-1]+5;
        }
        len=strlen(string);
    
        for(j=0;j<len;j++)
        {
           for(t=0;t<26;t++)
           {
           if(string[j]==alphabet[t])
           {
    	  b=t;
    	  i=5;
    	  if(t>9&&t<=19)
    	  {
    
    	     i+=5;
    	     b=t-10;
    	  }
    	  if(t>19)
    	  {
    	     i+=10;
    	     b=t-20;
    	  }
    
    	     flag=1;
    	     posx[j]=total_counter[b+1]+(b+1);
    	     posy[j]=i;
    	     for(f=0;f<j;f++)
    		{
    		  flag1=1;
    		   if(posx[j]==posx[f]&&posy[j]==posy[f])
    		     {
    
    			for(M=0;M<f;M++)
    			 {
    			 if(posx[f]==posx[M]&&posy[f]==posy[M])
    			   {
    			   gotoxy(total_counter[b+1]+(b+1),i-2);
    			   printf("%c",4);
    			   flag=0;
    			   flag1=0;
    			   }
    			 }
    			   if(flag1==1)
    			   {
    			  gotoxy(total_counter[b+1]+(b+1),i-1);
    
    			  printf("%c",4);
    			  flag=0;
    			  flag1=0;
    			    }
    
    		     }
    
    
    
    
    		}
    	     if(flag==1)
    	     {
    	     gotoxy(total_counter[b+1]+(b+1),i);
    
    	     printf("%c",4);
    	      }
    
    
           }
           }
        }
         _setcursortype(_NOCURSOR);
        getch();
        _setcursortype(_NORMALCURSOR);
        gotoxy(5,25);
        printf("\nPress ENTER to run again. Other wise press any other key...");
        if(getch()==13)
          goto TOP;
    
    }
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    goto is not very good style of programming
     
  3. sura

    sura Banned

    Joined:
    Aug 4, 2011
    Messages:
    47
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    India,Tamil Nadu.
    hey this only counts the character three times ........................
     

Share This Page