标题:错在哪里了呢?一运行就死
取消只看楼主
董世
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2012-11-26
结帖率:33.33%
已结贴  问题点数:20 回复次数:1 
错在哪里了呢?一运行就死
要求Define a structure type element_t to represent one element from the periodic table of elements.

以下是代码
程序代码:
#include<stdio.h>
struct element_t
{int number;

 char name[20];

 char symbol[2];

 float weight;

 int array[7];
};
void main()
{void scan_element(struct element_t *p);

 void printf_element(struct element_t *p);

 struct element_t ele;

 struct element_t *p;

 p=&ele;

 scan_element(p);

 printf_element(p);
}
void scan_element(struct element_t *p)
{int i;

 printf("\nPlease input some informations of one element:\n\nThe atomic number\nThe name\nChemical symbol\nA numeric field for the atomic weight\nA seven-element array of the integers for the number of electrons in each shell\n\n");

 scanf("%d%s%s%f",&(*p).number,&(*p).name,&(*p).symbol,&(*p).weight);

 for(i=0;i<7;i++)

 scanf("%d",&(*p).array[i]);
}
void printf_element(struct element_t *p)
{int i;

 printf("\nAtomic number: %d\nName: %s\nChemical symbol: %s\nAtomic weight: %f\n",(*p).number,(*p).name,(*p).symbol,(*p).weight);

 printf("Number of electrons in each shell is: ");

 for(i=0;i<7;i++)

 printf("%d ",(*p).array[i]);
}
搜索更多相关主题的帖子: one represent structure elements 
2012-12-03 12:54
董世
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2012-11-26
得分:0 
回复 3楼 wp231957
初学  还请老师们指点
2012-12-03 13:27



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-389370-1-1.html




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

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