小说网 找小说 无限小说 烟雨红尘 幻想小说 酷文学 深夜书屋

基于visual Studio2013解决C语言竞赛题之0303最大数




题目


解决代码及点评

这道题考察对条件分支和赋值的灵活应用

正常思维

如果 a>b and a>c 那么a最大

如果b>c and b>a 那么b最大

如果c>a and c>b 那么c最大

但是以上写法判断多,代码复杂


简单的做法是:

如果 a < b 那么 a = b

如果 a < c 那么 a = c

最后a是最大值


#include <stdio.h>
#include <stdlib.h>
void	main()
{
	int a,b,c;
	printf("please input a,b,c like a,b,c\n");
	scanf_s("%d,%d,%d",&a,&b,&c);
	if (a<b)  
	{
		a=b;
	}
	if (a<c)
	{
		a=c;
	}
	printf("\n最大数字为%d",a);
	system("pause");
}


代码下载及其运行

代码下载链接:

http://download.csdn.net/detail/yincheng01/6640573

解压密码为c.itcast.cn


下载解压后用VS2013打开工程文件 0201.vcxproj

点击 “本地Windows调试器” 执行


程序运行结果


输入三个数之后,程序输出最大值





posted on 2013-12-02 16:42  牛栏山1  阅读(143)  评论(0编辑  收藏  举报

导航