TOPIC

100% wrong

SHUVRA ADITYA (IIT_NSTU) (͡ ° ͜ʖ ͡ °) asked 2 years ago

it gives me 100% wrong. plz help me with code. .........

#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main()
{
    char line[1001], temp, ch1[1001];
    int n, i, j, k;
    scanf("%d",&n);
    for(k=0; k<n; k++)
    {

        fflush(stdin);
        scanf("%[^\n]",&line);

        for(i=0; i<strlen(line); i++)
        {
            if(isalpha(line[i]))
            {
                line[i]=line[i]+3;
            }
        }
        for ( i = 0, j = strlen(ch1)-1; i<strlen(ch1);i++,j--) {
            ch1[j] = line[i];
        }
        ch1[strlen(line)] = '\0';

        for(i=(strlen(line))/2; i<strlen(line); i++)
        {
            ch1[i]=ch1[i]-1;
        }
        printf("%s\n",ch1);
    }
    return 0;
}

Remember not post solutions. Your post may be reviewed by our moderators.

  • hema gamal replied 2 years ago

    a=strlen(arr);
        if(a%2==1)
            a++;
        for(int i=0; i<a/2; i++)
        {
            if(arr[i]>=' '&&arr[i]<='@')
                arr[i]-=1;
            else
            {
                arr[i]+=3;
                arr[i]-=1;
            }
        }
        for(int j=strlen(arr)-1; j>=a/2; j--)
        {
            if(!(arr[j]>=' '&&arr[j]<='@'))
                arr[j]+=3;
        }