流程图 编写一个程序,对输入的四个整数,求出其中的最大值和最小值

流程图 编写一个程序,对输入的四个整数,求出其中的最大值和最小值
using System;
using System.Collections.Generic;
using System.Text;
namespace Demo

class Program

static void Main(string[]args)

Console.Writeline(“请输入四个整数:”);
string str=Console.ReadLine()
string[]nums=input.Split(‘’);
long max=Convert.ToInt64(a[0]),min=max,tem;
foreach(string s in nums)

tem=Convert.ToInt64(s);
if(tem>max)
max=tem;
else if(tem<min)
min=tem;}
Console.WriteLine(“最大值是{0},最小值是{1}”,max,min);
Console.ReadKey(;)


#include<stdio.h>
main()
{
int a,b,c,d,max,min;
scanf("%d,%d,%d,%d",&a,&b,&c,&d);
max = a;min = a;
if(b>max) max = b;
if(c>max) max = c;
if(d>max) max = d;
if(b<min) min = b;
if(c<min) min = c;
if(d<min) min = d;
printf("max=%d,min=%d",max,min);
}
温馨提示:答案为网友推荐,仅供参考
相似回答