提交 b0d223c2 编写于 作者: 友聪 彭

添加项目文件。

上级 c7091d9e

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.421
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "数据结构作业1", "数据结构作业1\数据结构作业1.vcxproj", "{6C1105E7-A255-48FB-A8B1-0E0DEDBB4EF8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6C1105E7-A255-48FB-A8B1-0E0DEDBB4EF8}.Debug|x64.ActiveCfg = Debug|x64
{6C1105E7-A255-48FB-A8B1-0E0DEDBB4EF8}.Debug|x64.Build.0 = Debug|x64
{6C1105E7-A255-48FB-A8B1-0E0DEDBB4EF8}.Debug|x86.ActiveCfg = Debug|Win32
{6C1105E7-A255-48FB-A8B1-0E0DEDBB4EF8}.Debug|x86.Build.0 = Debug|Win32
{6C1105E7-A255-48FB-A8B1-0E0DEDBB4EF8}.Release|x64.ActiveCfg = Release|x64
{6C1105E7-A255-48FB-A8B1-0E0DEDBB4EF8}.Release|x64.Build.0 = Release|x64
{6C1105E7-A255-48FB-A8B1-0E0DEDBB4EF8}.Release|x86.ActiveCfg = Release|Win32
{6C1105E7-A255-48FB-A8B1-0E0DEDBB4EF8}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6AC80B9B-7296-4BD2-8464-6188926049C8}
EndGlobalSection
EndGlobal
// pch.cpp: 与预编译标头对应的源文件;编译成功所必需的
#include "pch.h"
// 一般情况下,忽略此文件,但如果你使用的是预编译标头,请保留它。
// 入门提示:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件
#ifndef PCH_H
#define PCH_H
// TODO: 添加要在此处预编译的标头
#endif //PCH_H
姓名 数学分析 高等代数 解析几何
张红 78 94 90
李丽君 65 73 82
成平 94 68 78
王伟 84 86 69
文锦春 74 92 60
林黛玉 66 83 70
付凌云 88 79 82
岳不群 90 82 93
令狐冲 81 77 97
温玉琪 95 84 68
胡建军 85 73 75
刘汉 90 87 89
秋昌平 83 71 74
秦敖天 96 92 95
方世杰 83 90 88
姓名 数学分析 高等代数 解析几何 平均成绩
张红 78 94 90 87.3
李丽君 65 73 82 73.3
成平 94 68 78 80.0
王伟 84 86 69 79.7
文锦春 74 92 60 75.3
林黛玉 66 83 70 73.0
付凌云 88 79 82 83.0
岳不群 90 82 93 88.3
令狐冲 81 77 97 85.0
温玉琪 95 84 68 82.3
胡建军 85 73 75 77.7
刘汉 90 87 89 88.7
秋昌平 83 71 74 76.0
秦敖天 96 92 95 94.3
方世杰 83 90 88 87.0
各科平均成绩 83.5 82.2 80.7
// 数据结构作业1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//此程序实现从scores.txt读取数据进行操作,并将操作结果写入scoresAnalysis.txt中
#include "pch.h"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#define MAX_LINE 16 //文件行数
using namespace std;
//定义结构体studentInfo
struct studentInfo
{
char name[10];
int nanlysis;
int algebra;
int analGeo;
double Average;
};
int main()
{
studentInfo student[MAX_LINE];//定义studentInfo结构体数组
char name[10];//学生姓名缓存
int l = 31;//跳过标题行
FILE *fp1;
//D:\\users\\lenovo\\source\\数据结构作业源代码\\数据结构作业1
fp1 = fopen("scores.txt","r");//创建文件句柄,打开用于读取数据
if (fp1 == NULL)//判断是否成功打开文档
cout << "打开失败" << endl;
//读取学生姓名
fseek(fp1, l, SEEK_SET);//文件指针移动到距文档开头l个偏移量
int i = 0;
while (fscanf(fp1, "%s%d%d%d", name,&student[i].nanlysis,&student[i].algebra,&student[i].analGeo) != EOF)//遍历文档读取学生姓名直到文档末尾
{
strcpy(student[i].name, name);//将学生姓名存入结构体
i++;
}
fclose(fp1);
//求学生平均成绩*/
double s1=0, s2=2, s3=0;
for (int n = 0; n < 15; n++)
{
student[n].Average = (student[n].nanlysis + student[n].algebra + student[n].analGeo) / 3.0;
s1 += student[n].nanlysis;
s2 += student[n].algebra;
s3 += student[n].analGeo;
}
//写入文档scoresAnalysis.txt中
FILE *ftp;
ftp = fopen("scoresAnalysis.txt", "w");//创建文件句柄,用于写入
if (ftp != NULL)
{
fprintf(ftp, "%s\t\t%s\t%s\t%s\t%s\n", "姓名","数学分析","高等代数 ","解析几何","平均成绩");//将字符串格式输入文档
for (int i = 0; i < 15; i++)
fprintf(ftp, "%s\t\t%d\t\t%d\t\t%d\t\t%.1f\n", student[i].name, student[i].nanlysis, student[i].algebra, student[i].analGeo, student[i].Average);
fprintf(ftp, "%s\t%.1f\t\t%.1f\t\t%.1f\n", "各科平均成绩", s1 / 15, s2 / 15, s3 / 15);
}
else
cout << "写入失败" << endl;
fclose(ftp);
//向屏幕打印文档scoresAnalysis.txt中的情况
FILE *f;
f= fopen("scoresAnalysis.txt", "r");
char buf[20];
cout << "scoresAnalysis.txt中的数据" << endl;
if (f != NULL)
{
while (fgets(buf, 20, f) != NULL)
{
cout << buf;
}
}
else
cout << "打开失败" << endl;
cout << "=========================" << endl;
cout << "Sp指向结构体读取scoresAnalysis.txt数据并输出" << endl;
FILE *f2;
f2 = fopen("scoresAnalysis.txt", "r");
studentInfo *Sp = new studentInfo;
char buf2[44];
fgets(buf2, 44, f2);
cout << buf2 ;
for (int i = 0; i < 15; i++)
{
fscanf(f2, "%s%d%d%d%lf", &Sp->name,&Sp->nanlysis,&Sp->algebra,&Sp->analGeo,&Sp->Average);
printf("%s\t\t%d\t\t%d\t\t%d\t\t%.1f\n", Sp->name, Sp->nanlysis, Sp->algebra, Sp->analGeo, Sp->Average);
}
fclose(f2);
return 0;
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{6C1105E7-A255-48FB-A8B1-0E0DEDBB4EF8}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>数据结构作业1</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="数据结构作业1.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="数据结构作业1.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册