C语言程序 用结构体编写一个程序,实现输入两个数,求出平均数 编写一个程序,求两个数的平均值(用C语言)

C\u8bed\u8a00\uff0c\u7f16\u5199\u4e00\u4e2a\u7a0b\u5e8f\u4ece\u952e\u76d8\u4e0a\u8f93\u5165\u4e24\u4e2a\u6574\u6570\uff0c\u5e76\u6c42\u51fa\u4e24\u4e2a\u6570\u7684\u5e73\u5747\u503c\u5728\u5c4f\u5e55\u4e0a\u8f93\u51fa\u7ed3\u679c

\u4ee3\u7801\u5982\u4e0b\uff1a
#include
int main()
{float a,b,c;printf("please enter number1:")
scanf("%f",&a)
printf("please enter number2:")
scanf("%f",&b)
c = (a+b)/2;printf("the result is %.1f\n",c);return 0;}
C\u8bed\u8a00\u7f16\u5199\u7a0b\u5e8f\u7684\u65b9\u6cd5\uff1a
visual c++6.0
\u62a5\u9519\u6bd4\u8f83\u51c6\u786e\uff0c\u4f46\u6bd4\u8f83\u96be\u7528\u3002\u662f\u5fae\u8f6f\u63a8\u51fa\u7684\u4e00\u6b3e\u7f16\u8bd1\u5668\uff0c\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u53ef\u89c6\u5316\u8f6f\u4ef6\u5f00\u53d1\u5de5\u5177\u3002

Turbo C 2.0
\u662fdos\u73af\u5883\u4e0b\u7684\uff0c\u6bd4\u8f83\u597d\u7528\uff0c\u4f46\u4e0d\u652f\u6301\u590d\u5236\uff0c\u7c98\u8d34\u7b49\u529f\u80fd\uff0c\u6bd4\u8f83\u4e0d\u597d\u7528\uff0c\u8981\u8bb0\u4f4f\u5e38\u7528\u7684\u51e0\u4e2a\u5feb\u6377\u952e\u3002

win-tc
\u7a97\u53e3\u4e0b\u7684tc\uff0c\u6bd4\u8f83\u597d\u7528\uff0c\u754c\u9762\u7b80\u6d01\uff0c\u7f8e\u89c2\u3002\u9002\u5408\u7f16\u4e00\u4e9b\u81ea\u5df1\u7528\u7684\u5c0f\u7a0b\u5e8f\u3002

Borland C++ Compiler
\u5b83\u662f\u7528\u6765\u4f18\u5316 BC \u5f00\u53d1\u7cfb\u7edf\u7684\u5de5\u5177\u3002\u5b83\u5305\u62ec\u6700\u540e\u7248\u672c\u7684 ANSI/ISO C++ \u8bed\u8a00\u7684\u652f\u6301\uff0c\u5305\u62ec RTL\uff0cC++ \u7684 STL\u6846\u67b6\u7ed3\u6784\u652f\u6301\u3002

Dev-C++
\u662f\u4e00\u4e2aWindows\u73af\u5883\u4e0bC/C++\u5f00\u53d1\u5de5\u5177\uff0c\u5b83\u662f\u4e00\u6b3e\u81ea\u7531\u8f6f\u4ef6\uff0c\u9075\u5b88GPL\u8bb8\u53ef\u534f\u8bae\u5206\u53d1\u6e90\u4ee3\u7801\u3002

\u4f8b\u5b50\u5982\u4e0b\uff1a

\u76f4\u63a5\u7f16\u8bd1\uff0c\u7a0b\u5e8f\u8f93\u51fa\u7ed3\u679c\u968f\u610f\u8f93\u5165\u4e24\u4e2a\u6570\uff0c\u5982100 \uff0c98\uff0c\u7a0b\u5e8f\u6267\u884c\u7ed3\u679c\u5982\u4e0b\u56fe\u6240\u793a\uff1a

\u77e5\u8bc6\u6269\u5c55\uff1a
\u7b97\u672f\u5e73\u5747\u6570\uff08 arithmetic mean\uff09\uff0c\u53c8\u79f0\u5747\u503c\uff0c\u662f\u7edf\u8ba1\u5b66\u4e2d\u6700\u57fa\u672c\u3001\u6700\u5e38\u7528\u7684\u4e00\u79cd\u5e73\u5747\u6307\u6807\uff0c\u5206\u4e3a\u7b80\u5355\u7b97\u672f\u5e73\u5747\u6570\u3001\u52a0\u6743\u7b97\u672f\u5e73\u5747\u6570\u3002\u5b83\u4e3b\u8981\u9002\u7528\u4e8e\u6570\u503c\u578b\u6570\u636e\uff0c\u4e0d\u9002\u7528\u4e8e\u54c1\u8d28\u6570\u636e\u3002
\u7b97\u672f\u5e73\u5747\u6570\u662f\u52a0\u6743\u5e73\u5747\u6570\u7684\u4e00\u79cd\u7279\u6b8a\u5f62\u5f0f\uff08\u7279\u6b8a\u5728\u5404\u9879\u7684\u6743\u91cd\u76f8\u7b49\uff09\u3002\u5728\u5b9e\u9645\u95ee\u9898\u4e2d\uff0c\u5f53\u5404\u9879\u6743\u91cd\u4e0d\u76f8\u7b49\u65f6\uff0c\u8ba1\u7b97\u5e73\u5747\u6570\u65f6\u5c31\u8981\u91c7\u7528\u52a0\u6743\u5e73\u5747\u6570\uff1b\u5f53\u5404\u9879\u6743\u76f8\u7b49\u65f6\uff0c\u8ba1\u7b97\u5e73\u5747\u6570\u5c31\u8981\u91c7\u7528\u7b97\u672f\u5e73\u5747\u6570\u3002

#include<stdio.h>
typedef struct stt
{
    float num;
}STT;
int main( )
{
    STT stt1,stt2;
    scanf("%f%f",&stt1.num,&stt2.num);
    printf("平均值:%f
",(stt1.num+stt2.num)/2);
    return 0;
}


#define <stdio.h>
struct A { int x,y; float av; } a;
void main() {
  scanf("%d%d",&a.x,&a.y); a.av=a.x+a.y; a.av/=2; printf("%f
",a.av);
}


扩展阅读:扫一扫题目出答案 ... c#简单程序 ... c#教程菜鸟 ... c#简单程序实例 ... c#编程练习题 ... c语言入门基础100题编程 ... c#考试题库 ... c语言程序设计题库及答案 ... c语言定义一个学生结构体 ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网