数组长这样
#include<stdio.h>
void main()
{
int x,y,i;
char a[][10]={
{"*****"},
{" **$**"},
{" *****"},
{" *****"},
{" *****"}
};
for(x=0;x<5;x++)
{
for(y=0;y<10;y++)
printf("%c",a[x][y]);
printf("\n");
}
while(1);
}
如何判定是否字符“$",有就输出其在二维数组的位置【如[1][0]】,没有就提示不存在
遍历比较就好了啊
int count = 0;
for(x=0;x<5;x++)
{
for(y=0;y<10;y++)
{
if(a[x][y] == '$')
{
printf("a[%d][%d]=$\n",x,y);
count++;
}
}
}
if(count == 0)
printf("不存在\n");
for(x=0;x<5;x++)
{
for(y=0;y<10;y++)
{
if(a[x][y]=='$'){
printf("%c",a[x][y]);
printf("%d%d",x,y);
printf("\n");
}
}
}