c语言
#include "stdio.h"typedef struct test //建立结构体{ int a; int b; int c;}T; T testt(int aa,int bb,int cc) //建立函数{ T aaa; aaa.a=aa*bb; aaa.b=aa*cc; aaa.c=bb*cc; return aaa; //返回结构} int main(){ T b=testt(4,5,6); printf("%d %d %d \n",b.a,b.b,b.c); T *f=&b; printf("%d %d %d",f->a,f->b,f->c);}
C++
#include "iostream"typedef struct sss //建立结构体{ int a; int b; int c;}S; S s(double a,double b,double c) 建立函数{ S d; d.a=a*a; d.b=b*b; d.c=c*c; return d;//返回结构体} int main(){ S z=s(3,4,5); std::cout<<z.a <<std::endl <<z.b <<std::endl <<z.c <<std::endl;}
0 条评论