求帮看下这哪里错了 北邮oj的108虚数题http://code.bupt.edu.cn/problem/p/108/

tudou_0 2016-03-20 08:20:06
#include <stdio.h>
#include <math.h>
#include <string.h>
struct num{
int a , b ;
char ch ;
double mo ;
} x[105] ;

int cmp(const void*x , const void*y){
const struct num *p = x ;
const struct num *q = y ;
return p->mo - q->mo ;
}
int main(){
char com[10] , ch1 ;
int t , n ;
int i , j ;
while(scanf("%d" , &t) != EOF){
while(t-- > 0){
scanf("%d" , &n) ;
j = 0 ;
i = 0 ;
while(j < n){
scanf("%s" , com) ;
if(0 == strcmp(com , "Insert")){
scanf("%d%c%c%d" , &x[i].a ,&x[i].ch , &ch1 , &x[i].b) ;
x[i].mo = sqrt( x[i].a*x[i].a + x[i].b*x[i].b ) ;
i ++ ;
printf("Size: %d\n" , i) ;
}else if(0 == strcmp(com , "Pop")){
if(0 == i){
printf("Empty!\n") ;
}else {
qsort(x , i , sizeof(struct num) , cmp) ;
printf("%d%ci%d\n" , x[i-1].a , x[i-1].ch , x[i-1].b) ;
i -- ;
if(0 != i){
printf("Size: %d\n" , i) ;
}else {
printf("Empty!\n") ;
}
}
}
j ++ ;
}
}
}
return 0 ;
}
...全文
229 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

703

社区成员

发帖
与我相关
我的任务
社区描述
提出问题
其他 技术论坛(原bbs)
社区管理员
  • community_281
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧