8 Mar 2013

graplin level-1 solved


/*

solution to graplin inline challenge level-1
*/




#include<stdio.h>
#include<conio.h>
#include<string.h>
void cutstr(char *,int ,int );
char arr1[150]={'\0'};char arr2[150]={'\0'};
char arr11[]="FourscoreandsevenyearsagoourfaathersbroughtforthonthiscontainentanewnationconceivedinzLibertyanddedicatedtothepropositionthatallmenarecreatedequalNowweareengagedinagreahtcivilwartestingwhetherthatnaptionoranynartionsoconceivedandsodedicatedcanlongendureWeareqmetonagreatbattlefiemldoftzhatwarWehavecometodedicpateaportionofthatfieldasafinalrestingplaceforthosewhoheregavetheirlivesthatthatnationmightliveItisaltogetherfangandproperthatweshoulddothisButinalargersensewecannotdedicatewecannotconsecratewecannothallowthisgroundThebravelmenlivinganddeadwhostruggledherehaveconsecrateditfaraboveourpoorponwertoaddordetract";
char arr12[]="TgheworldadswfilllittlenotlenorlongrememberwhatwesayherebutitcanneverforgetwhattheydidhereItisforusthelivingrathertobededicatedheretotheulnfinishedworkwhichtheywhofoughtherehavethusfarsonoblyadvancedItisratherforustobeherededicatedtothegreattdafskremainingbeforeusthatfromthesehonoreddeadwetakeincreaseddevotiontothatcauseforwhichtheygavethelastpfullmeasureofdevotionthatweherehighlyresolvethatthesedeadshallnothavediedinvainthatthisnationunsderGodshallhaveanewbirthoffreedomandthatgovernmentofthepeoplebythepeopleforthepeopleshallnotperishfromtheearth";

void main()
{ char *s;
strcpy(s,arr11);
strcat(s,arr12);
printf("\n%s",s);
for(int i=0;i<strlen(s);i++)
{ for(int j=i+1;j<=strlen(s);j++)
    {if(s[i]==s[j])
        {cutstr(s,i,j);
        }

    }

}


getch();
}

void cutstr(char *s,int i,int j)
{static flag=0;
int b=i;
for(int k=0;i<=j;i++,k++)
    {arr1[k]=s[i];
    }
arr1[k]='\0';

strcpy(arr2,arr1);
strrev(arr1);

if( strcmp(arr1,arr2)==0 && flag<j-b+1)
{printf("OUTPUT : %s",arr2);
flag=j-b+1;}
}

Categories: ,

0 comments:

Post a Comment

Copyright © UPgradeCODING | Powered by Blogger