懂点语言的都可以进啊

来源:百度知道 编辑:UC知道 时间:2024/05/14 03:43:25
我没学过C,光自己看了几页书,我比较两个数大小,你觉得这样可以啊,介怎么老有错啊,什么原因?还请懂的人帮我解释下,谢谢了! #include <stdio.h>
void main()
{ int a,b,t;
printf("enter a and b\n",);
scanf("%d,%d\n",&a,&b);
if (a>b);t=a;
else t=b;
printf("%d\n",t);
}
怎么运行都有错误, 错哪了啊? 在线等啊! 帮帮忙啊!

#include <iostream>
using namespace std;
void main()
{
int a,b,t;
cout << "enter a and b" << endl;
cin >> a >> b;
if (a>b)
{
t=a;
}
else
{
t=b;
}
cout << t <<endl;
}

-----------------
你在什么环境下? 以上代码vs2005编译通过

你用的TC?

if后没有分号

你的 if(a>b)后面的";"应该去掉,不去掉的话就是那个if语句什么也没执行! 无条件执行了 t=a 你改下,之后应该可以了。

首先就是,
if后没有分号
还有,
输入a b值时要注意:
输入了一个值后要输逗号,再输第二个值才行的

#include<stdio.h>
void main()
{
int a,b,t;
printf("enter a and b\n"); /*这里多了一个逗号,去掉了*/
scanf("%d,%d\n",&a,&b);
if (a>b) t=a; /*这里开始多了一个分号,去掉分号*/
else t=b;
printf("%d\n",t);
}

除了188890211

你们有运行看结果吗... 晕..