话说能不能请问个Microsoft Visual C++的有关问题
话说能不能请教个Microsoft Visual C++的问题
这学期学那个数据结构,使用c语言。
学校电脑用的是Microsoft Visual C++ 6.0,我估计我的w7装不了,就直接装的2010。
然后我估计2008的版本可以解答我这个问题,
然后2010版这个是怎么最初步的创建啊?
我刚学到头文件,然后应用举例。
头文件是这么写的:
typedef struct
{
DataType list[MaxSize];
int size;
}SeqList;
void ListInitiate(SeqList *L)
{
L->size= 0;
}
int ListLength(SeqList L)
{
return L.size;
}
int ListInsert(SeqList *L,int i,DataType x)
{
int j;
if(L->size>=MaxSize)
{
printf("顺序表已满无法插入!\n");
return 0;
}
else if(i < 0 || i > L->size)
{
printf("参数i不合法!\n");
return 0;
}
else
{
for(j = L->size; j > i; j--) L->list[j]=L->list[j-1];
L->list[i]= x;
L->size++;
return 1;
}
}
int ListDelete(SeqList *L,int i,DataType *x)
{
int j;
if(L->size<= 0)
{
printf("顺序表已空无数据元素可删!\n");
return 0;
}
else if(i < 0 || i > L->size-1)
{
printf("参数i不合法");
return 0;
}
else
{
*x = L->list[i];
for(j = i+1; j <=L->size-1; j++)L->list[j-1]=L->list[j];
L ->size--;
return 1;
}
}
然后举了个.cpp的例子是怎么写的
#include<stdio.h>
#define MaxSize 100
typedef struct Student
{
long number;
char name[10];
char sex[3];
int age;
} StudentType;
typedef StudentType DataType;
#include"SeqList.h"
void main(void)
{
SeqList myList;
int i;
StudentType x[3]={{2000001,"张三","男",20},
{2000002,"李四","男",21},
{2000003,"王五","男",22}};
StudentType s;
ListInitiate(&myList);
ListInsert(&myList,0,x[0]);
ListInsert(&myList,1,x[1]);
ListInsert(&myList,2,x[2]);
for(i = 0;i<ListLength(myList);i++)
{
if(ListGet(myList,i,&s)==0)
{
printf("错误! \n");
return;
}
else
printf("%d %s %s %d\n",s.number,s.name,s.sex,s.age);
}
}
我就是想问下,这2010版本里,这个写程序的那个文档怎么才能弄出来?
------解决方案--------------------
创建C++空白项目 右击解决资源管理器中的源文件 添加新建项 选择添加文件 可以是.cpp .h的
如果要添加C文件 在命名时候把cpp文件的命名成.C文件就行了
这学期学那个数据结构,使用c语言。
学校电脑用的是Microsoft Visual C++ 6.0,我估计我的w7装不了,就直接装的2010。
然后我估计2008的版本可以解答我这个问题,
然后2010版这个是怎么最初步的创建啊?
我刚学到头文件,然后应用举例。
头文件是这么写的:
typedef struct
{
DataType list[MaxSize];
int size;
}SeqList;
void ListInitiate(SeqList *L)
{
L->size= 0;
}
int ListLength(SeqList L)
{
return L.size;
}
int ListInsert(SeqList *L,int i,DataType x)
{
int j;
if(L->size>=MaxSize)
{
printf("顺序表已满无法插入!\n");
return 0;
}
else if(i < 0 || i > L->size)
{
printf("参数i不合法!\n");
return 0;
}
else
{
for(j = L->size; j > i; j--) L->list[j]=L->list[j-1];
L->list[i]= x;
L->size++;
return 1;
}
}
int ListDelete(SeqList *L,int i,DataType *x)
{
int j;
if(L->size<= 0)
{
printf("顺序表已空无数据元素可删!\n");
return 0;
}
else if(i < 0 || i > L->size-1)
{
printf("参数i不合法");
return 0;
}
else
{
*x = L->list[i];
for(j = i+1; j <=L->size-1; j++)L->list[j-1]=L->list[j];
L ->size--;
return 1;
}
}
然后举了个.cpp的例子是怎么写的
#include<stdio.h>
#define MaxSize 100
typedef struct Student
{
long number;
char name[10];
char sex[3];
int age;
} StudentType;
typedef StudentType DataType;
#include"SeqList.h"
void main(void)
{
SeqList myList;
int i;
StudentType x[3]={{2000001,"张三","男",20},
{2000002,"李四","男",21},
{2000003,"王五","男",22}};
StudentType s;
ListInitiate(&myList);
ListInsert(&myList,0,x[0]);
ListInsert(&myList,1,x[1]);
ListInsert(&myList,2,x[2]);
for(i = 0;i<ListLength(myList);i++)
{
if(ListGet(myList,i,&s)==0)
{
printf("错误! \n");
return;
}
else
printf("%d %s %s %d\n",s.number,s.name,s.sex,s.age);
}
}
我就是想问下,这2010版本里,这个写程序的那个文档怎么才能弄出来?
------解决方案--------------------
创建C++空白项目 右击解决资源管理器中的源文件 添加新建项 选择添加文件 可以是.cpp .h的
如果要添加C文件 在命名时候把cpp文件的命名成.C文件就行了