weixin_45629315
Do Myself forever
2019-10-09 22:03

救救孩子???指针数组

  • c语言

#include
int perimeter(int x,int y);
int area(int x,int y);
int solution(int x,int y,int(*ptr)());
int main()
{
int a,b;
printf(" 请输入A和B的值:");
scanf("%d%d",&a,&b);
printf(" Perimeter of a rectangle:");
solution(a,b,perimeter);
printf(" Area of a rectangle:");
solution(a,b,area);
}
int perimeter(int x,int y)
{
return (2*(x+y));
}
int area(int x,int y)
{
return x*y;
}
int solution(int x,int y,int(*ptr)())
{
int result;
result=(*ptr)(x,y);
printf("%d\n",result);
}

[Error] C:\Users\H\Documents\C-Free\Temp\未命名1.cpp:11: error: invalid conversion from int (*)(int, int)' toint (*)()'

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐