为什么c4能正常运行得到正确答案。cide不行?#inclu
cide吧
全部回复
仅看楼主
level 8
YYYYXoxoxo 楼主
为什么c4能正常运行得到正确答案。
cide不行?
#include <stdio.h>
#include <string.h>
int main(){
struct students {
char num[10];
int class1;
} stu[1000], ss;
for (int i = 0; i < 3; i++) {
scanf("%s%d",stu[i].num,&stu[i].class1);
}
for (int j = 0; j < 2;j++){
for (int k = 0; k < 2- j;k++)
if (strcmp(stu[j].num, stu[j + 1].num) == 1) {
ss = stu[j];
stu[j] = stu[j + 1];
stu[j + 1] = ss;
}
}
for (int i = 0; i < 3; i++)
printf("%s\n", stu[i].num);
return 0;
}
2017年12月27日 16点12分 1
level 8
哪里都不对
2017年12月27日 23点12分 3
的确全是错。。。。昨晚上我这是咋了[汗][喷]
2017年12月28日 01点12分
level 8
strcmp返回值只保证<0,=0,>0不保证==1。例外你的2层循环干啥的?
2017年12月28日 00点12分 4
呃,不好意思记错了😣
2017年12月28日 01点12分
1