Click here to Skip to main content
13,764,207 members

C / C++ / MFC

 
QuestionReferencing a class in other in a other class Pin
ForNow28-Oct-18 4:43
memberForNow28-Oct-18 4:43 
AnswerRe: Referencing a class in other in a other class Pin
Victor Nijegorodov28-Oct-18 8:35
memberVictor Nijegorodov28-Oct-18 8:35 
GeneralRe: Referencing a class in other in a other class Pin
ForNow28-Oct-18 8:37
memberForNow28-Oct-18 8:37 
GeneralRe: Referencing a class in other in a other class Pin
Richard MacCutchan28-Oct-18 12:34
protectorRichard MacCutchan28-Oct-18 12:34 
GeneralRe: Referencing a class in other in a other class Pin
Stefan_Lang31-Oct-18 4:59
memberStefan_Lang31-Oct-18 4:59 
AnswerRe: Referencing a class in other in a other class Pin
Joe Woodbury28-Oct-18 10:02
professionalJoe Woodbury28-Oct-18 10:02 
AnswerRe: Referencing a class in other in a other class Pin
Bram van Kampen2-Nov-18 15:31
memberBram van Kampen2-Nov-18 15:31 
QuestionPrivate test case failed Pin
Member 1403429426-Oct-18 10:35
memberMember 1403429426-Oct-18 10:35 
The question was-[![Go to the link][1]][1]


  [1]: https://i.stack.imgur.com/KtjQm.png
My code-

    #include <stdio.h>
    #include<stdlib.h>
    #include<math.h>
    void main()
    {
        int r,c,i,j,t=0;
        scanf("%d",&r);
        scanf("%d",&c);
        int a[r][c];
        int counter=0;
        for(i=0;i<r;i++) //taking the input row wise
        {
            for(j=0;j<c;j++)
            {
                scanf("%d",&a[i][j]);
            }
            printf("\n");
        }
        for(i=1;i<(r-1);i++) //Taking the inner elements
        {
            for(j=1;j<(c-1);j++)
            {
                t=t+1;
                int count=0;
                if(a[i][j-1]==0)
                count+=1;
                if(a[i][j+1]==0)
                count+=1;
                if(a[i-1][j]==0)
                count+=1;
                if(a[i+1][j]==0)
                count+=1;
                if(count==3)
                printf("%d\n",a[i][j]);
                else
                counter+=1;
                 
            }
        }
        if (counter ==t) //Checking whether the counter equals the inner elements
        {
            printf("No peninsular elements");
        }
    }

My logic is to take each inner element and then find its surrounding element. If the surrounding element is 0, then I am increasing my count by 1 otherwise I am increasing counter by 1. If my count equals 3 at the end of the loop, then I am printing that element. 

I am getting a private test case failed error when I am running it on my university site. Is there any flaw in my logic that I can rectify to overcome this error. 

SuggestionRe: Private test case failed Pin
Richard MacCutchan26-Oct-18 23:41
protectorRichard MacCutchan26-Oct-18 23:41 
QuestionRe: Private test case failed Pin
David Crow29-Oct-18 8:11
memberDavid Crow29-Oct-18 8:11 
QuestionCatch javascript event in CHtmlView Pin
_Flaviu24-Oct-18 0:37
member_Flaviu24-Oct-18 0:37 
AnswerMessage Closed Pin
24-Oct-18 1:48
member_Flaviu24-Oct-18 1:48 
GeneralRe: Catch javascript event in CHtmlView Pin
_Flaviu26-Oct-18 2:14
member_Flaviu26-Oct-18 2:14 
AnswerRe: Catch javascript event in CHtmlView Pin
Afzaal Ahmad Zeeshan24-Oct-18 1:51
mvpAfzaal Ahmad Zeeshan24-Oct-18 1:51 
Questiondouble signed comparison in C++ Pin
kamal197723-Oct-18 17:42
memberkamal197723-Oct-18 17:42 
AnswerRe: double signed comparison in C++ Pin
CPallini23-Oct-18 21:47
mvpCPallini23-Oct-18 21:47 
AnswerRe: double signed comparison in C++ Pin
Victor Nijegorodov23-Oct-18 22:04
memberVictor Nijegorodov23-Oct-18 22:04 
Questionclistctrl class Pin
Jim Overby23-Oct-18 9:01
memberJim Overby23-Oct-18 9:01 
AnswerRe: clistctrl class Pin
Victor Nijegorodov23-Oct-18 9:11
memberVictor Nijegorodov23-Oct-18 9:11 
AnswerRe: clistctrl class Pin
Joe Woodbury23-Oct-18 9:29
professionalJoe Woodbury23-Oct-18 9:29 
SuggestionRe: clistctrl class Pin
David Crow23-Oct-18 10:34
memberDavid Crow23-Oct-18 10:34 
Questionhelp Pin
sabrina life19-Oct-18 8:54
membersabrina life19-Oct-18 8:54 
AnswerRe: help Pin
OriginalGriff19-Oct-18 9:00
protectorOriginalGriff19-Oct-18 9:00 
GeneralRe: ? Pin
sabrina life19-Oct-18 9:21
membersabrina life19-Oct-18 9:21 
RantRe: ? Pin
David Crow19-Oct-18 11:04
memberDavid Crow19-Oct-18 11:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Cookies | Terms of Service
Web01-2016 | 2.8.181113.4 | Last Updated 14 Nov 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid