本人成功改写了一个简单的程序
原程序是比较两个数的大小,代码如下# include <stdio.h>
int maxValue(int, int); /*函数声明*/
main( )
{
int x, y, z;
printf("Enter 2 integers:");
scanf("%d%d", &x, &y);
z = maxValue(x,y);
printf("The larger value is %d.",z);
}
int maxValue(int x, int y)
{
int max;
if (x<y)
max=x;
else
max=y;
return max;
}
我把它成功改写成比较三个数的大小,代码如下
# include <stdio.h>
int maxValue(int, int, int); // 函数声明
int main()
{
int x, y, z, o;
printf("Enter 3 integers:");
scanf("%d%d%d", &x, &y, &o);
z = maxValue(x, y, o);
printf("The larger value is %d.", z);
}
int maxValue(int x, int y, int o)
{
int max;
if (x > y, x > o)
max = x;
else if (o > x, o > y)
max = o;
else
max = y;
return max;
} vb秒虐你
dim a,b,c,max as integer
max=a
if b>max then max=b
if c>max then max=c
print max 不明觉厉 http://yunpan.cn/Q9ymenBqsZMdf
不好,没达到预期结果,比较1 2 3的大小最大的数居然是2
我应该怎么修改呢? **** 作者被禁止或删除 内容自动屏蔽 **** python 不说话了. 水区已经丧心病狂到这地步了吗。。。 成功搞定,代码如下
#include<stdio.h>
// 包含头文件stdio.h
int main()
// 定义main函数为基本整形(int)变量
{
printf("Please enter 3 numbers:\n");
// 在屏幕上显示文字"Please enter 3 numbers."
int x, y, z;
// 定义x,y,z为基本整形(int)变量
scanf("%d%d%d", &x, &y, &z);
// 输入x,y,z
if (x < y)
x = y;
// 如果x<y,则把y的值赋给x
if (x < z)
x = z;
// 如果x<z,则把z的值赋给x
printf("The largest number is %d.", x);
// 显示"The largerest number is x."
return 0;
// 使main函数的值为0
} 总算是成功了,代码如下
#include<stdio.h>
// 包含头文件stdio.h
int main()
// 定义main函数为基本整形(int)变量
{
printf("Please enter 3 numbers:\n");
// 在屏幕上显示文字"Please enter 3 numbers."
int x, y, z;
// 定义x,y,z为基本整形(int)变量
scanf("%d%d%d", &x, &y, &z);
// 输入x,y,z
if (x < y)
x = y;
// 如果x<y,则把y的值赋给x
if (x < z)
x = z;
// 如果x<z,则把z的值赋给x
printf("The largest number is %d.", x);
// 显示"The largerest number is x."
return 0;
// 使main函数的值为0
} 勿入此贴,沉了吧 [quote]vb秒虐你
dim a,b,c,max as integer
max=a
if b>max then max=b
if c>max then max=c
print max
[size=2][color=#999999]dej.sf 发表于 2013-10-26 01:29[/color] [url=http://bbs.theworld.cn/redirect.php?goto=findpost&pid=1614650&ptid=226345][img]http://bbs.theworld.cn/images/common/back.gif[/img][/url][/size][/quote]
VB写程序快,但运行比VC慢 所以我等吊丝喜欢写VB
不喜欢VC 程序员都应该被烧死tw107yct 烧 +1046
页:
[1]