Posts

Showing posts from February, 2018

Remove First And Last Till End

Image
C Code: #include<stdio.h> #include <stdlib.h> int main() { int i=0,j,k,l,l1,c=0; char s[1000]; scanf("%s",s); l=strlen(s); char a[l]; if(l%2==0) l1=l/2; else l1=l/2+1; while(s[i]!='\0') { a[i]=s[i]; i++; } while(c<l1) { for(i=c;i<l;i++) { printf("%c",a[i]); }printf("\n"); c++; l--; } } Java Code: import java.util.*; public class Hello {     public static void main(String[] args) { Scanner sc=new Scanner(System.in); String s=sc.nextLine(); char ch[]=s.toCharArray(); int i,j,k,m,l=ch.length; for(i=0;i<l;i++) System.out.print(ch[i]); System.out.println(); j=0;m=0; for(k=1;k<l/2+1;k++) {     j++;     while(j<l-k)     {           System.out.print(ch[j]);         j++;     }     m++;     j=m;     System.out.println(); } } }