c语言常见问题问题,,,请大神回答???

C语言链表有关问题,求大神解答!标题长长长长长长长长长长长长长长长长长长一点! - C语言当前位置:& &&&C语言链表有关问题,求大神解答!标题长长长长长长C语言链表有关问题,求大神解答!标题长长长长长长长长长长长长长长长长长长一点!www.MyException.Cn&&网友分享于:&&浏览:0次C语言链表问题,求大神解答!标题长长长长长长长长长长长长长长长长长长一点!!本帖最后由 xdz78 于
11:04:42 编辑
#include&&stdio.h&
#include&&stdlib.h&
struct&student
&&&&struct&student&*
struct&student&*creat(int&n)
&&&&struct&student&*p1,*p2;
&&&&int&i;
&&&&p1=(struct&student*)malloc(sizeof(struct&student));
&&&&head=p1;
&&&&for(i=0;i&n;i++)
&&&&&&&&p1-&score=i+1;
&&&&&&&&p2=(struct&student*)malloc(sizeof(struct&student));
&&&&&&&&p1-&next=p2;
&&&&&&&&p1=p2;
&&&&p1-&next=NULL;
&&&&return&
void&print(int&*head,int&n)
&&&&struct&student&*p1;
&&&&while&(p1-&next-&next!=NULL)
&&&&&&&&printf("%d&",p1-&score);
&&&&&&&&p1=p1-&
&&&&printf("%d\n",p1-&score);
int&main()
&&&&int&N;
&&&&struct&student&*
&&&&head=struct&student&*creat(N);&&&&&&&&&&//&这里error了
&&&&scanf("%d",&N);
&&&&struct&student&*&creat(N);
&&&&print(head,N);
&&&&return&0;
||===&Build:&Debug&in&约瑟夫问题&(compiler:&GNU&GCC&Compiler)&===|
D:\codeblocks&--project\约瑟夫问题\main.c||In&function&'creat':|
D:\codeblocks&--project\约瑟夫问题\main.c|16|warning:&assignment&from&incompatible&pointer&type&[enabled&by&default]|
D:\codeblocks&--project\约瑟夫问题\main.c|25|warning:&return&from&incompatible&pointer&type&[enabled&by&default]|
D:\codeblocks&--project\约瑟夫问题\main.c||In&function&'print':|
D:\codeblocks&--project\约瑟夫问题\main.c|31|warning:&assignment&from&incompatible&pointer&type&[enabled&by&default]|
D:\codeblocks&--project\约瑟夫问题\main.c||In&function&'main':|
D:\codeblocks&--project\约瑟夫问题\main.c|44|error:&expected&expression&before&'struct'|
D:\codeblocks&--project\约瑟夫问题\main.c|46|warning:&parameter&names&(without&types)&in&function&declaration&[enabled&by&default]|
D:\codeblocks&--project\约瑟夫问题\main.c|47|warning:&passing&argument&1&of&'print'&from&incompatible&pointer&type&[enabled&by&default]|
D:\codeblocks&--project\约瑟夫问题\main.c|28|note:&expected&'int&*'&but&argument&is&of&type&'struct&student&*'|
||===&Build&failed:&1&error(s),&5&warning(s)&(0&minute(s),&0&second(s))&===|
1.为什么会报错呢?
2.程序中的函数struct&student&*creat(int&n)为什么要加*号?
3.如果我把开头改成
struct&student
&&&&struct&student&*
}N//加了个Node
这个Node是不是只能在调用结构体中的元素时使用?比如:Node.score
能不能说结构体后面加个Node的作用等同于typedef&struct&student&Node?------解决思路----------------------struct&student&*creat(int&n)返回student指针,但是你的head是int型。------解决思路----------------------#include&&stdio.h&
#include&&stdlib.h&
struct&student
struct&student&*
struct&student&*creat(int&n)
struct&student&*p1,&*p2;
p1&=&(struct&student*)malloc(sizeof(struct&student));
struct&student&*
head&=&p1;
for&(i&=&0;&i&n;&i++)
p1-&score&=&i&+&1;
p2&=&(struct&student*)malloc(sizeof(struct&student));
p1-&next&=&p2;
p1-&next&=&NULL;
void&print(struct&student&*head,&int&n)
struct&student&*p1;
while&(p1-&next-&next&!=&NULL)
printf("%d&",&p1-&score);
printf("%d\n",&p1-&score);
int&main()
struct&student&*
scanf("%d",&&N);
head&=&creat(N);
print(head,&N);
12345678910
12345678910
12345678910 上一篇:下一篇:文章评论相关解决方案 1234567891011 Copyright & &&版权所有求解决-c语言问题求解,请大神们指教
作者:用户
浏览:933 次
c语言问题求解,请大神们指教本题要求实现一个对数组进行循环右移的简单函数:一个数组aa中存有nn(&0&0)个整数,将每个整数循环向右移mm(ge0≥0)个位置,即将aa中的数据由(a_
c语言问题求解,请大神们指教
本题要求实现一个对数组进行循环右移的简单函数:一个数组aa中存有nn(&0&0)个整数,将每个整数循环向右移mm(ge 0≥0)个位置,即将aa中的数据由(a_0 a_1 cdots a_{n-1}a
?? )变换为(a_{n-m} cdots a_{n-1} a_0 a_1 cdots a_{n-m-1}a
?? )(最后mm个数循环移至最前面的mm个位置)。
函数接口定义:
int ArrayShift( int a[], int n, int m );
其中a[]是用户传入的数组;n是数组的大小;m是右移的位数。函数ArrayShift须将循环右移后的数组仍然存在a[]中。#include
#define MAXN 10
int ArrayShift( int a[], int n, int m );
int main()
int a[MAXN], n,
scanf("%d %d", &n, &m);
for ( i = 0; i & i++ ) scanf("%d", &a[i]);
ArrayShift(a, n, m);
for ( i = 0; i & i++ ) {
if (i != 0) printf(" ");
printf("%d", a[i]);
/* 你的代码将被嵌在这里 */
解决方案二:
【云栖快讯】直播推荐——现在报名3月12日编程语言系列讲座,与行业资深专家一起学习Python、C++、JavaScript、Java!还可在活动页面领取红包,百分百中奖哦!&&
弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率
40+云计算产品,6个月免费体验
稳定可靠、可弹性伸缩的在线数据库服务,全球最受欢迎的开源数据库之一
IT采购开年惠,百款产品5折起,新购满额再返最高6000!17:09 提问
c语言取小数问题,急求大神解答!
程序是#include
int main()
float a,b;
scanf("%f",&a);
n=(1000*a+0.5);
b=(n*1.0)/1000;
printf("%f",b);
输入123.4567
输出是123.457001
输入12345.67
为什么会这样呢?求大神解答!
按赞数排序
你去百度下浮点数的存储格式。机器只能识别0,1,需要二进制转换成十进制。理论上,有限位数的二进制浮点数必能转换为有限位数的十进制数;但对于有限位数的十进制浮点数,转换为二进制数不能保证是有限位数,且多数情况下不是有限位数。因此,如果提供足够的输出位数,二进制浮点数可以精确转换为十进制数,不产生转换误差。但是,由于没有一个2n与lOm(n,m为整数)相等,二进制和十进制相互转换的位数没有简单的若干位对应若干位的对应关系。一般地,二进制浮点数向十进制转换都只提供若干位的近似值,并不提供全部的数字位数。事实上更主要的原因是:计算机中表示的二进制浮点数绝大多数本身就是实际数值的近似值,从有效数字的角度看,转换为十进制数时提供更多位数字并无使用价值。这里自然就有一个如何看待和精确使用数值的问题,即有效数字位数的问题。尤其对于各种数值计算,必须掌握其有效数字位数。但查阅有关资料,没有看到对计算机中浮点数的有效数字位数的准确叙述,一般仅指出fIoat和doubIe型大致的有效数字位数,且说法不一,没有给出依据。在此,从相对误差(误差绝对值与数值绝对值的比值)的角度给出一般性的结论。原文
----------------------同志你好,我是CSDN问答机器人小N,奉组织之命为你提供参考答案,编程尚未成功,同志仍需努力!
float的精度为6~7位有效数字,多出的就可能产生误差。
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐求助大神c语言问题(2&3)&&(x=5)结果是1?(2&3)&&(x=5)结果是5?为什么?
(2&3)&&(x=5)结果是1?(2&3)&&(x=5)结果是5?为什么?
逻辑运算符
的运算顺序是从左往右,若左边的关系表达式就能判断整个逻辑表达式的结果,就不计算右边表达式;否则执行。这个称为短路。
(2&3) && (x=5)
左边2&3为假,所以整个表达式就为假,右边的表达式不执行。
你还没有登录,请先登录或注册慕课网帐号
#include &stdio.h&
int main(){
printf("%d\n",(2&3)&&(x=5));//0
printf("%d\n",(2&3)&&(x=5));//1
}#include &stdio.h&
int main(){
int y=(2&3)&&(x=5);//x=1,2&3已经为假了,后面的直接省略了不去计算了,加快程序的运行效率
int z=(2&3)&&(x=5);//x=5
你还没有登录,请先登录或注册慕课网帐号
二元运算符&&的顺序是
运行A 如果A为真,则运行B…如果A为假直接返回整个表达式为假。
所以表达式子中,2&3为假…所以直接返回值,没有运行B.
你还没有登录,请先登录或注册慕课网帐号
24483人关注
14367人关注
7280人关注
Copyright (C) 2018 imooc.com All Rights Reserved | 京ICP备 号-11

我要回帖

更多关于 c语言常见问题 的文章

 

随机推荐