<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://www.gentoo-zh.org/extern.php?action=feed&amp;tid=409&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Gentoo中文社区 / C 练习实例100]]></title>
		<link>https://www.gentoo-zh.org/viewtopic.php?id=409</link>
		<description><![CDATA[C 练习实例100 最近发表的帖子。]]></description>
		<lastBuildDate>Mon, 29 Aug 2022 11:58:48 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[C 练习实例100]]></title>
			<link>https://www.gentoo-zh.org/viewtopic.php?pid=415#p415</link>
			<description><![CDATA[<p>题目：有五个学生，每个学生有3门课的成绩，从键盘输入以上数据（包括学生号，姓名，三门课成绩），计算出平均成绩，况原有的数据和计算出的平均分数存放在磁盘文件&quot;stud&quot;中。</p><p>程序分析：无。</p><p>程序源代码：</p><br /><div class="codebox"><pre class="vscroll"><code>#include&lt;stdio.h&gt;
#include&lt;stdlib.h&gt;
typedef struct{
    int ID;
    int math;
    int English;
    int C;
    int avargrade;
    char name[20];
}Stu;
int main()
{
    FILE*fp;
    Stu stu[5];
    int i,avargrade=0;
    printf(&quot;请输入5个同学的信息：学生号，姓名，3门成绩:\n&quot;);
    for(i=0;i&lt;5;i++)
    {
        scanf(&quot;%d %s %d %d %d&quot;,&amp;(stu[i].ID),stu[i].name,&amp;(stu[i].math),&amp;(stu[i].English),&amp;(stu[i].C));
        stu[i].avargrade=(stu[i].math+stu[i].English+stu[i].C)/3;
    }
    
    if((fp=fopen(&quot;stud&quot;,&quot;w&quot;))==NULL)
    {
        printf(&quot;error :cannot open file!\n&quot;);
        exit(0);
    }
    for(i=0;i&lt;5;i++)
        fprintf(fp,&quot;%d %s %d %d %d %d\n&quot;,stu[i].ID,stu[i].name,stu[i].math,stu[i].English,
                stu[i].C,stu[i].avargrade);
    
    fclose(fp);
    // system(&quot;pause&quot;);
    return 0;
}</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (batsom)]]></author>
			<pubDate>Mon, 29 Aug 2022 11:58:48 +0000</pubDate>
			<guid>https://www.gentoo-zh.org/viewtopic.php?pid=415#p415</guid>
		</item>
	</channel>
</rss>
