# include<stdio.h>
typedef struct student {
int id;
}stu;
int jiaohuan(stu a);
int main(void)
{
stu a;
int b;
scanf_s("%d", &a.id);
b=jiaohuan(a);
printf("%d", b);
return 0;
}
int jiaohuan(stu a)
{
a.id = 10;
return(a.id);
}
运行结果配图
#include<stdio.h>
typedef struct student {
int id;
double score;
}stu;
void bianhuan(stu *p)
{
p->id = 6;
(*p).score = 100;
}
int main(void)
{
stu a;
a.id = 5;
a.score = 10;
bianhuan(&a);
printf("%lf\n", a.score);
printf("%3.0d\n", a.id);
return 0;
}
运行结果配图
# include<stdio.h>
typedef struct student {
int id;
}stu;
void jiaohuan(stu *p)
{
(*p).id = 5;
}
int main(void)
{
stu b;
stu *a=&b;
jiaohuan(a);
printf("%d", a->id);
return 0;
}
运行结果配图
# include<stdio.h>
typedef struct com {
float Realpart;
float Imagepart;
}Complex;
void Create(Complex *c, float x, float y);
int main(void)
{
float a, b;
scanf_s("%f%f", &a, &b);
Complex c;
Create(&c,a,b);
printf("%.0f %.0f", c.Realpart, c.Imagepart);
return 0;
}
void Create(Complex *c, float x, float y)
{
(*c).Realpart = x;
c->Imagepart = y;
}
运行结果配图
# include<stdio.h>
typedef struct com{
float Realpart;
float Imagepart;
}Complex;
void Create(Complex *c, float x, float y);
int main(void)
{
float a, b;
scanf_s("%f%f", &a, &b);
Complex c;
Create(&c, a, b);
printf("%f%f", c.Realpart, c.Imagepart);
return 0;
}
void Create(Complex *c, float x, float y)
{
(*c).Realpart = x;
c->Imagepart = y;
}
运行结果配图