CrazyEngineers
  • raj.kmolkar
    raj.kmolkar

    MemberAug 19, 2011

    Help with code

    [FONT="] [/FONT][FONT="]Given a string and a number ‘n’, find the ‘n’th distinct repeating character. [/FONT]

    [FONT="]For example, [/FONT]
    [FONT="]Input:[/FONT]
    [FONT="]Abracadabra, 1[/FONT]
    [FONT="]Abracadabra, 2[/FONT]
    [FONT="]Abracadabra, 3[/FONT]
    [FONT="]Abracadabra, 4[/FONT]
    [FONT="] [/FONT]
    [FONT="]Output[/FONT]
    [FONT="]a[/FONT]
    [FONT="]b[/FONT]
    [FONT="]r[/FONT]
    [FONT="]null[/FONT]
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Bharath51

    MemberAug 21, 2011

    #include<stdio.h>
    #include<conio.h>
    #include<string.h>
    void main()
    {
    char arr[10],c;
    int n,i,count=0;
    clrscr();
    printf("Enter the string:");
    gets(arr);
    printf("enter the position\n");
    scanf("%d",&n);
    c=arr[n];
    i=n-1;
    for(i;i>=0;i--)
    if(arr==c)
    count++;


    if(count>=1 )
    printf("\nnull");
    else
    printf("\n%d",n);


    getch();
    }
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register