鱼C论坛

 找回密码
 立即注册
查看: 2269|回复: 4

这道题错在哪

[复制链接]
发表于 2011-12-9 14:48:22 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
#include<stdio.h>
#define NULL 0
struct student
{
long num;
float score;
struct student *next;
};
void main()
{
struct student a,b,c,*head,*p;
a.num=10101;a.score=89.5;
b.num=10103;b.score=90;
c.num=10107;c.score=85;
head=&a;
a.next=&b;
b.next=&c;
c.next=NULL;
p=head;
do
{
  printf("ld%5.1f\n",p->num,p->score);
  p=p->next;
} while(p!=NULL);
}


在VC++运算老是显示0,不知道什么原因
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2011-12-9 17:46:52 | 显示全部楼层
  1. #include<stdio.h>
  2. #define NULL 0
  3. struct student
  4. {
  5.         long num;
  6.         float score;
  7.         struct student *next;
  8. };
  9. void main()
  10. {
  11.         struct student a,b,c,*head,*p;
  12.         a.num=10101;a.score=89.5;
  13.         b.num=10103;b.score=90;
  14.         c.num=10107;c.score=85;
  15.         head=&a;
  16.         a.next=&b;
  17.         b.next=&c;
  18.         c.next=NULL;
  19.         p=head;
  20.         do
  21.         {
  22.                 //printf("ld%5.1f\n",p->num,p->score);
  23.                 printf("%d%5.1f\n",p->num,p->score);
  24.                 p=p->next;
  25.         } while(p!=NULL);
  26. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2011-12-9 20:02:53 | 显示全部楼层
#include<stdio.h>
//#define NULL 0
struct student
{
        long  num;
        float score;
        struct student *next;
};
int main()
{
        struct student a,b,c,*head,*p;
        a.num=10101;a.score=89.5;
        b.num=10103;b.score=90;
        c.num=10107;c.score=85;
        head=&a;
        a.next=&b;
        b.next=&c;
        c.next=NULL;
        p=head;
        do
        {
                printf("%ld%5.1f\n",p->num,p->score);
                p=p->next;
        } while(p!=NULL);
        return 0;
}
~                             
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2011-12-9 20:03:21 | 显示全部楼层
ld前掉了%
小甲鱼最新课程 -> https://ilovefishc.com
发表于 2011-12-9 22:28:22 | 显示全部楼层
各种学习!!
小甲鱼最新课程 -> https://ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-11-9 23:44

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表