1158: 又是排序(指针专题)expected declaration or statement at end of input
2018-09-09 16:43
211 查看
版权声明:写作不易,转载请注明作者和出处。如果对您有帮助,支付宝搜索534165486领个小红包,谢谢~~~///(^v^)\\\~~~ https://blog.csdn.net/Bear_Two_/article/details/82559679
1158: 又是排序(指针专题)
时间限制: 1 Sec 内存限制: 128 MB
题目描述
将输入的四个整数按由大到小的顺序输出。
已定义如下swap函数,可实现形参pa和pb所指内存单元的内容交换。请务必使用本函数实现两个变量内容的互换。
void swap( int *pa, int *pb)
{
int t;
t=*pa; *pa=*pb; *pb=t;
}
输入
输入4个整数,用空格隔开。
输出
输出排序后的4个整数,由空格隔开。输出占一行。
样例输入
[code]4 3 5 2
样例输出
[code]5 4 3 2
expected declaration or statement at end of input
[code] #include<stdio.h> #define maxn 100 void swap( int *pa, int *pb); int main(){ int i,j,a[maxn]; for(i=0;i<4;i++){ scanf("%d",&a[i]); } for(i=0;i<3;i++){ for(j=i+1;j<4;j++){ if(a[i]<a[j]) swap(&a[i],&a[j]); } } for(i=0;i<4;i++) { printf("%d ",a[i]); } return 0; }// <--- 就是缺少这个位置的括号 void swap( int *pa, int *pb) { int t; t=*pa; *pa=*pb; *pb=t; }
今天刷题的时候碰见上面这个错误,令我很奇怪,后来查询原因,是少了一个大括号。
支付宝搜索"534165486"领个小红包吧
相关文章推荐
- error:expected declaration or statement at end of input
- error: expected declaration or statement at end of input----solved
- 错误提示expected declaration or statement at end of input
- C语言错误:expected declaration or statement at end of input
- “ error: expected declaration or statement at end of input/n warning: control reaches end of non-void function”
- C语言错误:expected declaration or statement at end of input
- error: expected declaration or statement at end of input
- C语言错误:expected declaration or statement at end of input
- error: expected declaration or statement at end of input----solved
- 错误: expected declaration or statement at end of input
- expected declaration or statement at end of input
- expected declaration or statement at end of input
- error: expected declaration or statement at end
- Cocos2d-x 3.0 TestCpp android编译出错 解决 error: expected ';' at end of member declaration
- Cocos2d-x 3.0 编译出错 解决 error: expected ';' at end of member declaration
- Cocos2d-x 3.0 编译出错 解决 error: expected ';' at end of member declaration
- Cocos2d-x 3.0 编译出错 解决 error: expected '' at end of member declaration
- python读取xml文件报错xml.parsers.expat.ExpatError: XML or text declaration not at start of entity
- android retrofit End of input at line 1 column 1 path
- iOS 9出现错误Applications are expected to have a root view controller at the end of application launch