Find the index of the column and the row that contains the same number sequence












0















I want to find the index of the column and the row that contains the same number sequence in a 2D array.
for example



{2, 3, 2, 6} 
{3, 6, 3, 10}
{7, 4, 2, 12}
{6, 8, 6, 4}


in this example, the program must return the line index 0 and the column index 2
I wrote a program using C language but it doesn't work



# include <stdio.h>
int main(){
char tab[3][3];
int simiLgn, simiClm;
for (int i = 0; i<3; i++){
for (int j = 0; j<3; j++){
printf("Tableau[%d][%d]=", i, j);
scanf("%d", &tab[i][j]);
}
}

for (int i = 0; i<3; i++){
for (int j = 0; j<3; j++){
printf("%d t", tab[i][j]);
}
printf("n");
}


int fix_lgn = 0;
int fix_col = 0;
while (fix_lgn<3){
while (fix_col<3){
for (int i=0, j=0; i<3, j<3 ; i++, j++){
if(tab[fix_lgn][j] == tab[i][fix_col]){
simiLgn = fix_lgn;
simiClm = fix_col;
}
else{
simiLgn = -1;
simiClm = -1;
}
}
fix_col++;

}
fix_col = 0;
fix_lgn++;
}

printf("ligne index: %dn", simiLgn);
printf("colonne index: %dn", simiClm);

return 0;
}


Thank you










share|improve this question




















  • 1





    i<3, j<3 this doesn't do what you think, switch to i<3 && j<3, and here: tab[fix_lgn, j] you want tab[fix_lgn][j]

    – Keine Lust
    Nov 24 '18 at 20:58








  • 1





    @KeineLust You are right, but in this loop i does not make a difference because i and j are both always equal.

    – Werner Henze
    Nov 24 '18 at 21:00






  • 2





    @WernerHenze, you are right, anyway the OP should know it

    – Keine Lust
    Nov 24 '18 at 21:04











  • @WernerHenze @ KeineLust thanks for help i will try to update the code

    – hamza
    Nov 24 '18 at 21:38
















0















I want to find the index of the column and the row that contains the same number sequence in a 2D array.
for example



{2, 3, 2, 6} 
{3, 6, 3, 10}
{7, 4, 2, 12}
{6, 8, 6, 4}


in this example, the program must return the line index 0 and the column index 2
I wrote a program using C language but it doesn't work



# include <stdio.h>
int main(){
char tab[3][3];
int simiLgn, simiClm;
for (int i = 0; i<3; i++){
for (int j = 0; j<3; j++){
printf("Tableau[%d][%d]=", i, j);
scanf("%d", &tab[i][j]);
}
}

for (int i = 0; i<3; i++){
for (int j = 0; j<3; j++){
printf("%d t", tab[i][j]);
}
printf("n");
}


int fix_lgn = 0;
int fix_col = 0;
while (fix_lgn<3){
while (fix_col<3){
for (int i=0, j=0; i<3, j<3 ; i++, j++){
if(tab[fix_lgn][j] == tab[i][fix_col]){
simiLgn = fix_lgn;
simiClm = fix_col;
}
else{
simiLgn = -1;
simiClm = -1;
}
}
fix_col++;

}
fix_col = 0;
fix_lgn++;
}

printf("ligne index: %dn", simiLgn);
printf("colonne index: %dn", simiClm);

return 0;
}


Thank you










share|improve this question




















  • 1





    i<3, j<3 this doesn't do what you think, switch to i<3 && j<3, and here: tab[fix_lgn, j] you want tab[fix_lgn][j]

    – Keine Lust
    Nov 24 '18 at 20:58








  • 1





    @KeineLust You are right, but in this loop i does not make a difference because i and j are both always equal.

    – Werner Henze
    Nov 24 '18 at 21:00






  • 2





    @WernerHenze, you are right, anyway the OP should know it

    – Keine Lust
    Nov 24 '18 at 21:04











  • @WernerHenze @ KeineLust thanks for help i will try to update the code

    – hamza
    Nov 24 '18 at 21:38














0












0








0








I want to find the index of the column and the row that contains the same number sequence in a 2D array.
for example



{2, 3, 2, 6} 
{3, 6, 3, 10}
{7, 4, 2, 12}
{6, 8, 6, 4}


in this example, the program must return the line index 0 and the column index 2
I wrote a program using C language but it doesn't work



# include <stdio.h>
int main(){
char tab[3][3];
int simiLgn, simiClm;
for (int i = 0; i<3; i++){
for (int j = 0; j<3; j++){
printf("Tableau[%d][%d]=", i, j);
scanf("%d", &tab[i][j]);
}
}

for (int i = 0; i<3; i++){
for (int j = 0; j<3; j++){
printf("%d t", tab[i][j]);
}
printf("n");
}


int fix_lgn = 0;
int fix_col = 0;
while (fix_lgn<3){
while (fix_col<3){
for (int i=0, j=0; i<3, j<3 ; i++, j++){
if(tab[fix_lgn][j] == tab[i][fix_col]){
simiLgn = fix_lgn;
simiClm = fix_col;
}
else{
simiLgn = -1;
simiClm = -1;
}
}
fix_col++;

}
fix_col = 0;
fix_lgn++;
}

printf("ligne index: %dn", simiLgn);
printf("colonne index: %dn", simiClm);

return 0;
}


Thank you










share|improve this question
















I want to find the index of the column and the row that contains the same number sequence in a 2D array.
for example



{2, 3, 2, 6} 
{3, 6, 3, 10}
{7, 4, 2, 12}
{6, 8, 6, 4}


in this example, the program must return the line index 0 and the column index 2
I wrote a program using C language but it doesn't work



# include <stdio.h>
int main(){
char tab[3][3];
int simiLgn, simiClm;
for (int i = 0; i<3; i++){
for (int j = 0; j<3; j++){
printf("Tableau[%d][%d]=", i, j);
scanf("%d", &tab[i][j]);
}
}

for (int i = 0; i<3; i++){
for (int j = 0; j<3; j++){
printf("%d t", tab[i][j]);
}
printf("n");
}


int fix_lgn = 0;
int fix_col = 0;
while (fix_lgn<3){
while (fix_col<3){
for (int i=0, j=0; i<3, j<3 ; i++, j++){
if(tab[fix_lgn][j] == tab[i][fix_col]){
simiLgn = fix_lgn;
simiClm = fix_col;
}
else{
simiLgn = -1;
simiClm = -1;
}
}
fix_col++;

}
fix_col = 0;
fix_lgn++;
}

printf("ligne index: %dn", simiLgn);
printf("colonne index: %dn", simiClm);

return 0;
}


Thank you







c arrays






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 '18 at 15:28







hamza

















asked Nov 24 '18 at 20:54









hamzahamza

158




158








  • 1





    i<3, j<3 this doesn't do what you think, switch to i<3 && j<3, and here: tab[fix_lgn, j] you want tab[fix_lgn][j]

    – Keine Lust
    Nov 24 '18 at 20:58








  • 1





    @KeineLust You are right, but in this loop i does not make a difference because i and j are both always equal.

    – Werner Henze
    Nov 24 '18 at 21:00






  • 2





    @WernerHenze, you are right, anyway the OP should know it

    – Keine Lust
    Nov 24 '18 at 21:04











  • @WernerHenze @ KeineLust thanks for help i will try to update the code

    – hamza
    Nov 24 '18 at 21:38














  • 1





    i<3, j<3 this doesn't do what you think, switch to i<3 && j<3, and here: tab[fix_lgn, j] you want tab[fix_lgn][j]

    – Keine Lust
    Nov 24 '18 at 20:58








  • 1





    @KeineLust You are right, but in this loop i does not make a difference because i and j are both always equal.

    – Werner Henze
    Nov 24 '18 at 21:00






  • 2





    @WernerHenze, you are right, anyway the OP should know it

    – Keine Lust
    Nov 24 '18 at 21:04











  • @WernerHenze @ KeineLust thanks for help i will try to update the code

    – hamza
    Nov 24 '18 at 21:38








1




1





i<3, j<3 this doesn't do what you think, switch to i<3 && j<3, and here: tab[fix_lgn, j] you want tab[fix_lgn][j]

– Keine Lust
Nov 24 '18 at 20:58







i<3, j<3 this doesn't do what you think, switch to i<3 && j<3, and here: tab[fix_lgn, j] you want tab[fix_lgn][j]

– Keine Lust
Nov 24 '18 at 20:58






1




1





@KeineLust You are right, but in this loop i does not make a difference because i and j are both always equal.

– Werner Henze
Nov 24 '18 at 21:00





@KeineLust You are right, but in this loop i does not make a difference because i and j are both always equal.

– Werner Henze
Nov 24 '18 at 21:00




2




2





@WernerHenze, you are right, anyway the OP should know it

– Keine Lust
Nov 24 '18 at 21:04





@WernerHenze, you are right, anyway the OP should know it

– Keine Lust
Nov 24 '18 at 21:04













@WernerHenze @ KeineLust thanks for help i will try to update the code

– hamza
Nov 24 '18 at 21:38





@WernerHenze @ KeineLust thanks for help i will try to update the code

– hamza
Nov 24 '18 at 21:38












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462272%2ffind-the-index-of-the-column-and-the-row-that-contains-the-same-number-sequence%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462272%2ffind-the-index-of-the-column-and-the-row-that-contains-the-same-number-sequence%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Ottavio Pratesi

Tricia Helfer

15 giugno