Click here to Skip to main content
15,867,308 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionReferencing a class in other in a other class Pin
ForNow28-Oct-18 3:43
ForNow28-Oct-18 3:43 
AnswerRe: Referencing a class in other in a other class Pin
Victor Nijegorodov28-Oct-18 7:35
Victor Nijegorodov28-Oct-18 7:35 
GeneralRe: Referencing a class in other in a other class Pin
ForNow28-Oct-18 7:37
ForNow28-Oct-18 7:37 
GeneralRe: Referencing a class in other in a other class Pin
Richard MacCutchan28-Oct-18 11:34
mveRichard MacCutchan28-Oct-18 11:34 
GeneralRe: Referencing a class in other in a other class Pin
Stefan_Lang31-Oct-18 3:59
Stefan_Lang31-Oct-18 3:59 
AnswerRe: Referencing a class in other in a other class Pin
Joe Woodbury28-Oct-18 9:02
professionalJoe Woodbury28-Oct-18 9:02 
AnswerRe: Referencing a class in other in a other class Pin
Bram van Kampen2-Nov-18 14:31
Bram van Kampen2-Nov-18 14:31 
QuestionPrivate test case failed Pin
Member 1403429426-Oct-18 9:35
Member 1403429426-Oct-18 9: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 22:41
mveRichard MacCutchan26-Oct-18 22:41 
QuestionRe: Private test case failed Pin
David Crow29-Oct-18 7:11
David Crow29-Oct-18 7:11 
QuestionCatch javascript event in CHtmlView Pin
_Flaviu23-Oct-18 23:37
_Flaviu23-Oct-18 23:37 
AnswerMessage Closed Pin
24-Oct-18 0:48
_Flaviu24-Oct-18 0:48 
GeneralRe: Catch javascript event in CHtmlView Pin
_Flaviu26-Oct-18 1:14
_Flaviu26-Oct-18 1:14 
AnswerRe: Catch javascript event in CHtmlView Pin
Afzaal Ahmad Zeeshan24-Oct-18 0:51
professionalAfzaal Ahmad Zeeshan24-Oct-18 0:51 
Questiondouble signed comparison in C++ Pin
kamal197723-Oct-18 16:42
kamal197723-Oct-18 16:42 
AnswerRe: double signed comparison in C++ Pin
CPallini23-Oct-18 20:47
mveCPallini23-Oct-18 20:47 
AnswerRe: double signed comparison in C++ Pin
Victor Nijegorodov23-Oct-18 21:04
Victor Nijegorodov23-Oct-18 21:04 
Questionclistctrl class Pin
Jim Overby23-Oct-18 8:01
Jim Overby23-Oct-18 8:01 
AnswerRe: clistctrl class Pin
Victor Nijegorodov23-Oct-18 8:11
Victor Nijegorodov23-Oct-18 8:11 
AnswerRe: clistctrl class Pin
Joe Woodbury23-Oct-18 8:29
professionalJoe Woodbury23-Oct-18 8:29 
SuggestionRe: clistctrl class Pin
David Crow23-Oct-18 9:34
David Crow23-Oct-18 9:34 
Questionhelp Pin
sabrina life19-Oct-18 7:54
sabrina life19-Oct-18 7:54 
AnswerRe: help Pin
OriginalGriff19-Oct-18 8:00
mveOriginalGriff19-Oct-18 8:00 
GeneralRe: ? Pin
sabrina life19-Oct-18 8:21
sabrina life19-Oct-18 8:21 
RantRe: ? Pin
David Crow19-Oct-18 10:04
David Crow19-Oct-18 10: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.