Ha593 2022-05-19 21:18 采纳率: 95.2%
浏览 29
已结题

怎样在main函数里面调用其它函数,输出函数的返回值

#include <stdio.h>
#include

using namespace std;
#define Size 8 //顺序表的容量大小

struct table {
int size; //顺序表的容量大小(形参)
int length;//顺序表的有效长度,及数组中的元素个数
int* head;//动态数组
};

void Initlist()
{
table t;
t.length = 0;
t.size=Size;
t.head = new int[t.size];

int i;
int n;
cout<<"输入"<<n<<"的值";
cin>>n;
for (i = 0; i < n; i++)
{
cout << endl<<"输入第" << i + 1 << "个数据:";
cin >> t.head[i];
t.length++;
}
};

int Listsize(table t) //求顺序表的容量大小
{
return t.size;
}

int Listlength(table t)//求顺序表中数组的元素个数
{
return t.length;
}

int Listhead(table t)//求顺序表中数组的各元素
{
int i;
int n=0;
for (i = 0; i < n; i++)
return t.head[i];
}

int main()
{
Listsize();
Listlength();
Listhead();
return 0;
}

  • 写回答

1条回答 默认 最新

  • 缓慢前进的小菜 2022-05-19 21:21
    关注

    函数名加参数 ListLength(table类型的参数)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 5月27日
  • 已采纳回答 5月19日
  • 修改了问题 5月19日
  • 创建了问题 5月19日

悬赏问题

  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表