CHGSTRUC.C
资源名称:C.rar [点击查看]
上传用户:qq5388545
上传日期:2022-07-04
资源大小:29849k
文件大小:1k
源码类别:
界面编程
开发平台:
C/C++
- #include <stdio.h>
- struct Shape {
- int type;
- int color;
- float radius;
- float area;
- float perimeter;
- };
- void change_structure(struct Shape *shape)
- {
- (*shape).type = 0;
- (*shape).color = 1;
- (*shape).radius = 5.0;
- (*shape).area = 22.0 / 7.0 * (*shape).radius * (*shape).radius;
- (*shape).perimeter = 2.0 * 22.0 / 7.0 * (*shape).radius;
- }
- void main(void)
- {
- struct Shape circle;
- change_structure(&circle);
- printf("circle.type %dn", circle.type);
- printf("circle.color %dn", circle.color);
- printf("circle.radius %f circle.area %f circle.perimeter %fn",
- circle.radius, circle.area, circle.perimeter);
- }