输入
1021202
2022310
8102134
1030912
3110203
4021205
#
没有结果输出,统计二三位是02正常应该是3
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
char code[8];
struct node *next;
};
int main(void){
struct node *head,*p;
int count=0,size=sizeof(struct node);
char str[8];
head=NULL;
gets(str);
while(strcmp(str,"#")!=0){
p=(struct node *)malloc (size);
strcpy(p->code,str);
head=p->next;
head=p;
gets(str);
}
for(p=head;p->next!=NULL;p=p->next)
if(p->code[1]=='0'&&p->code[2]=='2')
count++;
printf("%d\n",count);
return 0;
}
C语言统计专业人数未解出
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- CSDN专家-link 2021-07-04 11:29关注
head=p->next;
head=p;
这样写肯定是不行啊。head赋值两遍算啥啊。应该是p->next = head; head = p;本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 乘性高斯噪声在深度学习网络中的应用
- ¥15 运筹学排序问题中的在线排序
- ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
- ¥30 求一段fortran代码用IVF编译运行的结果
- ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
- ¥15 C++ 头文件/宏冲突问题解决
- ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
- ¥50 安卓adb backup备份子用户应用数据失败
- ¥20 有人能用聚类分析帮我分析一下文本内容嘛
- ¥30 python代码,帮调试,帮帮忙吧