| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1070 人关注过本帖
标题:我编译一个程序,有问题,大家帮忙找下!
取消只看楼主 加入收藏
whbc
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:180
专家分:139
注 册:2010-3-31
结帖率:89.66%
收藏
已结贴  问题点数:20 回复次数:5 
我编译一个程序,有问题,大家帮忙找下!
程序代码:
#include <stdio.h>
void main()
{
    char *name[]={" ","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
    int week;
    char **pp=name;
    while(1)
    {
        printf("enter seek No.:");
        scanf("%d",&week);
        if(week<1||week>7)
            break;
        printf("Week No. %d-->%s\n",week,**(pp+week));
    }
}
就这个了,大家看看!!
搜索更多相关主题的帖子: 编译 
2010-12-18 22:36
whbc
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:180
专家分:139
注 册:2010-3-31
收藏
得分:0 
回复 2楼 zhaoya881010
比如你输入7,你就可以得到答案sunday了!就这样!但是我用vc运行时,输入一个数后,他显示内存不能为读!

付出终将有回报!Ibelieve!
2010-12-18 22:46
whbc
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:180
专家分:139
注 册:2010-3-31
收藏
得分:0 
回复 5楼 aufish
ok!谢谢了!

付出终将有回报!Ibelieve!
2010-12-18 22:56
whbc
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:180
专家分:139
注 册:2010-3-31
收藏
得分:0 
回复 6楼 zhaoya881010
谢了!!

付出终将有回报!Ibelieve!
2010-12-18 22:58
whbc
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:180
专家分:139
注 册:2010-3-31
收藏
得分:0 
对了,谁能帮我改改这个程序,也是同样的问题!!
程序代码:
#include <stdio.h>
#include <stdlib.h>


 struct student

 { 
     char name[8];
     float high;
     long int weight;
     struct student *next;

 };


 int n,i;

 struct student *creat()//创建链表
 { 
      i=1;
     struct student *p,*head,*stud;
     head=NULL;
     stud=p=(struct student *)malloc(sizeof(struct student));
     printf("请输入学生 %d 的身高体重姓名:",i);
     scanf("%f%ld%s",&stud->high,&stud->weight,stud->name);
     fflush(stdin);
     while(stud->high!=0)           //以学生的身高来判断循环
     {
         n++;
         if(n==1)
         {  
             head=stud;
             head->next=NULL;
         }
         else
             p->next=stud;
             p=stud;
          stud=(struct student *)malloc(sizeof(struct student));
          printf("请输入学生 %d 的姓名身高体重:",++i);
          scanf("%f%ld%s",&stud->high,&stud->weight,stud->name);
          fflush(stdin);
     }
     p->next=NULL;
     return(head);

 }



 struct student * search(struct student *head)//找出高度最高的那个学生
 {  
     struct student *p,*q,*t;
     t=p=head;
     if(head!=NULL)
     do
     { 
         if(t->high<p->high)
         {
              q=p;
         }
         p=p->next;
     }while(p!=NULL);
         return q;


 }


 struct student * find(struct student *head)//找出体重最重的那个学生
 { 
     struct student *p,*q,*t;
     t=p=head;
     if(head!=NULL)
     do
     {
         if(t->weight<p->weight)
         {
            q=p;
         }
         p=p->next;
     }while(p!=NULL);
    
    return q;

 }



 void  main(void)

 { 
     struct student *p,*q,*head;
     head=creat();
     p=search(head);
     printf("%s%f%ld",p->high,p->weight,p->name);
     q=find(head);
     printf("%s%f%ld",q->high,q->weight,q->name);
     
     

 }

付出终将有回报!Ibelieve!
2010-12-18 22:59
whbc
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:180
专家分:139
注 册:2010-3-31
收藏
得分:0 
嗯。行

付出终将有回报!Ibelieve!
2010-12-18 23:03
快速回复:我编译一个程序,有问题,大家帮忙找下!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015276 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved