I have 2D array in size of [temp][26] filled with the char '#' or nothing. some rows are empty, some rows filled with that char. how I print only the rows that are filled.
我有[temp] [26]大小的2D数组,用char'#'填充或什么也没有。有些行是空的,有些行用char填充。我如何只打印填充的行。
this is my start.
这是我的开始。
for (i=0;i<(temp);i++){
for (j=0;j<26;j++)
printf("%c",graph[temp][j]);
printf("\n");
}
2 个解决方案
#1
4
Just use a 'if' condition ... I don't see your problem
只是使用'if'条件......我没有看到你的问题
for (i=0;i<(temp);i++){
for (j=0;j<26;j++)
if(graph[temp][j] == '#') printf("%c",graph[temp][j]);
printf("\n");
}
#2
1
If you meant you want to print only the rows filled with '#' and all of them:
如果您的意思是只想打印带有'#'的行以及所有行:
for (i=0;i<(temp);i++)
if(graph[temp][0] == '#') //check only first character will be enough
printf("%s\n",graph[temp]); //print all current line
printf("\n");
#1
4
Just use a 'if' condition ... I don't see your problem
只是使用'if'条件......我没有看到你的问题
for (i=0;i<(temp);i++){
for (j=0;j<26;j++)
if(graph[temp][j] == '#') printf("%c",graph[temp][j]);
printf("\n");
}
#2
1
If you meant you want to print only the rows filled with '#' and all of them:
如果您的意思是只想打印带有'#'的行以及所有行:
for (i=0;i<(temp);i++)
if(graph[temp][0] == '#') //check only first character will be enough
printf("%s\n",graph[temp]); //print all current line
printf("\n");