C语言中出现cannot convert parameter 1 from 'char [9][3]' to 'char []'
源代码为#include<stdio.h>#include<string.h>voidchangeinto(chara[],charb[]);charmoney[][4]...
源代码为#include <stdio.h>
#include <string.h>
void changeinto(char a[],char b[]);
char money[][4]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
char a[][3]={"元","拾","佰","仟","万","拾","佰","仟","亿"};
void main()
{
char b[10];
printf("please input money\n");
gets(b);
changeinto(a,b);
}
void changeinto(char a[],char b[])
{
int i,j=0,n=strlen(b);
for(i=0;i<n;i++)
j=a[i]-'0';
printf("%s",a[j]);
} 展开
#include <string.h>
void changeinto(char a[],char b[]);
char money[][4]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
char a[][3]={"元","拾","佰","仟","万","拾","佰","仟","亿"};
void main()
{
char b[10];
printf("please input money\n");
gets(b);
changeinto(a,b);
}
void changeinto(char a[],char b[])
{
int i,j=0,n=strlen(b);
for(i=0;i<n;i++)
j=a[i]-'0';
printf("%s",a[j]);
} 展开
3个回答
2011-11-29
展开全部
编译问题是改好了,但是你的程序逻辑有问题,自己找一找吧,
#include <stdio.h>
#include <string.h>
void changeinto(char b[]);
char money[][4]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
char a[][3]={"元","拾","佰","仟","万","拾","佰","仟","亿"};
void main()
{
char b[10];
printf("please input money\n");
gets(b);
changeinto(b);
}
void changeinto(char b[])
{
int i,j=0,n=strlen(b);
for(i=0;i<n;i++)
j=a[i][0]-'0';
printf("%s",a[j]);
}
提示一下:
钱数依次取最高位,将最高位值和money匹配,将最高位的位数和a匹配
#include <stdio.h>
#include <string.h>
void changeinto(char b[]);
char money[][4]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
char a[][3]={"元","拾","佰","仟","万","拾","佰","仟","亿"};
void main()
{
char b[10];
printf("please input money\n");
gets(b);
changeinto(b);
}
void changeinto(char b[])
{
int i,j=0,n=strlen(b);
for(i=0;i<n;i++)
j=a[i][0]-'0';
printf("%s",a[j]);
}
提示一下:
钱数依次取最高位,将最高位值和money匹配,将最高位的位数和a匹配
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
有几个错误,注意注释处:
#include <stdio.h>
#include <string.h>
void changeinto(char (*a)[3],char b[]); /* a[] */
char money[][4]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
char a[][3]={"元","拾","佰","仟","万","拾","佰","仟","亿"};
void main()
{
char b[10];
printf("please input money\n");
gets(b);
changeinto(a,b);
}
void changeinto(char (*a)[3],char b[]) /* a[] */
{
int i,j=0,n=strlen(b);
for(i=0;i<n;i++){
j=b[i]-'0'; /* a[i] */
printf("%s",a[j]);}
}
#include <stdio.h>
#include <string.h>
void changeinto(char (*a)[3],char b[]); /* a[] */
char money[][4]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
char a[][3]={"元","拾","佰","仟","万","拾","佰","仟","亿"};
void main()
{
char b[10];
printf("please input money\n");
gets(b);
changeinto(a,b);
}
void changeinto(char (*a)[3],char b[]) /* a[] */
{
int i,j=0,n=strlen(b);
for(i=0;i<n;i++){
j=b[i]-'0'; /* a[i] */
printf("%s",a[j]);}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2011-11-29
展开全部
参数传递要匹配,二维不能传给一维
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询