#include<stdio.h>
#include<math.h>
main()
{
int a,b,c,i,j;
printf("please input three side(数以空格分开):\n");
int A[3];
int t;
scanf("%d %d %d",&a,&b,&c);
A[0]=a;A[1]=b;A[2]=c;
for(j=0;j<2;j++)
for(i=0;i<2-j;i++)
if(A[i]>A[i+1])
{
t=A[i];
A[i]=A[i+1];
A[i+1]=t;
}
a=A[0];b=A[1];c=A[2];
printf("%d > %d > %d",c,b,a);
while(1);
}
这个...好多符号我不认识啊,超出我的学习范围了吧?能不能换个简单的?谢谢
追答/*这个是循环的,还可以是if来判断的
#include
int main(){
return 0;
}你可以改成这样的
*/
#include
using namespace std;
void main(){
int i,j,k;
int a[3];
int max;
while(scanf("%d%d%d",&a[0],&a[1],&a[2])==3){
for(i=0;imax){
max=a[j];
k=j;
}
}
a[k]=a[i];
a[i]=max;
printf("%d ",a[i]);
if(i==2)
printf("\n");
max=0;
}
}
}
这个就是排序出来啊,3个数,我发的两个程序都可以排序啊,第一个是要输入排多少个数字,第二个程序是排序3个数字,你都不运行下吗
iostream using namespace std; viod sort cin......还有好几个不认识啊...
追答这个是C++里面的。iostream这个就是 ,,using namespace std这句话是格式总要带上。cin就是输入。cout就是输出。坑爹呀。我忘记C语言的术语了。就是几个词不同,你用C语言替换下。自己能替换出来才算对这个基础程序看懂了。函数什么的都没变。
追问\documents and settings\administrator\64龚俊xt3-1.cpp(4) : error C2065: 'viod' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'sort'
: error C2065: 'sort' : undeclared identifier
error C2144: syntax error : missing ')' before type 'int' error C2059: syntax error : ')'
: error C2373: 'sort' : rede
这个就是软件提示的错误...晕啊
viod打错了。改成void这是个没有返回值的函数。if(x>y) {temp=x,x=y,y=temp;}
这个后面加分号; 尝试分析错误。