求三个数中最大的数 C++代码 #include using namespace std; int main() { int a,b,c; int f(int x,int y,int z); cin>>a>>b>>c; c=f(a,b,c); cout<<c<<endl; return 0; } int f(int x,int y,int z) { int m; if (x<y) m=x; else m=y; if (z<
任输入三个数,求得平均值,平均值程序(VB6.0源代码编写Function ave(ByVal a As Double, ByVal b As Double, ByVal c As Double) As Double ave = (a + b + c) / 3 End Function Private Sub Command1_Click() Text4 = ave(Val(Text1), Val(Text2), Val(Text3)) End Sub
#include
int main(void)
{
/********* Begin *********/
int a,b,c,max;
scanf("%d,%d,%d,&a,&b,&c");
max=a;
if(max<b);
max=b;
if(max<c);
max=c;
printf("max=%d",max);
/********* End *********
问题:输入三个整数x,y,z,请把这三个数由小到大输出。
程序分析:
(1)先将x与y进行比较,如果x>y则将x与y的值进行交换。
(2)然后将 x与z进行比较,如果x>z则将x与z的值进行交换,这样能使x最小。
(3)最后将y与z进行比较,如果y>z则将y与z的值进行交换。
C实现:
#define _CRT_SECURE_NO_WARNINGS
#include
void Print(int a, int b, int c) {
printf(“%d,%d,%d\n”, a