请检查我的代码 [英] check my code Please

查看:89
本文介绍了请检查我的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include <iostream>
#include<string>
using namespace std ;
struct NodeType 
{
	string Name ;
	int Grade ;
	NodeType *Link ;
};
class TotalLinkedList 
{
private :
	NodeType *Pass ;
	NodeType *Fail ;
	int CountPass ;
	int CountFail ;

public :
	void insert (string , int ) ;
	void deleteNode (int);
	int searchName(string);
	string FindMax () ;
	double PrintAverage ();
	void Print();
	TotalLinkedList ();
	~TotalLinkedList();
	TotalLinkedList (TotalLinkedList&);
};
TotalLinkedList::TotalLinkedList() 
{
	Pass = 0 ;
	Fail = 0 ;
	CountPass =0 ;
	CountFail = 0; 
}
void TotalLinkedList::insert (string name ,int grade )
{
  NodeType *P ,*F , *C=new NodeType , *D=new NodeType ;
  P=new NodeType ;
  F= new NodeType ;
 
  if (grade >=50&&grade<=100 )
  {
	  if (Pass==0)
		  Pass=P;
       P->Grade = grade ;
	   P->Name=name ;
	   P->Link = Pass ;
	  P->Link =Pass ;
	  CountPass++ ;
      for ( int i=0 ; i<countpass mode="hold" />	  { 
		  C=C->Link ;
		  C->Link =P ;
		  P->Link = Pass ;
		  Pass = P ; }}
  else 
	 
	  if (grade <=50 &&grade>0 )
  {
	  if (Fail==0)
		  Fail=F;
       F->Grade = grade ;
	   F->Name=name ;
	   F->Link = Fail ;
	  F->Link =Fail ;
	  CountFail++ ;
	  
	  C=0;

      for ( int i=0 ; i<countfail mode="hold" />	  { 
		  C=C->Link ;
		  C->Link =F ;
		  F->Link = Fail ;
		 Fail = F ; }}
	  else 
		  cout <<" Can not insert " << endl;

}
int TotalLinkedList::searchName(string name)
{

	for(int i=0 ; i<countpass;i++)>
	{
		if(Pass->Name==name)
			return Pass->Grade;
		else 
			if (Fail->Name==name)
				return Fail->Grade ;
	}
}
 
string TotalLinkedList:: FindMax () 
{
	 
	NodeType *C=Pass;
	int Max = Pass->Grade ;
	for (int i=0;i<countpass;i++)>
	{
		
		
		if (C->Grade>Max)
			Max=C->Grade;
		
		C=C->Link;
		
	}
	return C->Name ; 
}




double TotalLinkedList::PrintAverage ()
{
	int sum1=0,sum2=0 , SUM=0 , average;
	for (int i=0 ; i<countpass;i++)>
	{
		sum1=sum1 + Pass->Grade ;
	}
	for (int i=0 ; i<countfail;i++)>
	{
		sum2=sum2 + Fail->Grade ;
	}
	SUM=sum1+sum2;
		average = SUM/(CountPass+CountFail) ;
		return average ;
}
void TotalLinkedList::Print()
{
	NodeType *c ;
	c=Pass;
	for (int i =0 ;i<countpass;i++)>
	{
		cout << c->Name << " " << c->Grade ;
		c=c->Link ;
	}
	c=0;
	c=Fail;
	for (int i =0 ;i<countfail;i++)>
	{
		cout << c->Name << " " << c->Grade ;
		c=c->Link ;
	}

}
TotalLinkedList::~TotalLinkedList()
{
	delete Pass ;
	delete Fail ;

}

int main ()
{
	TotalLinkedList Obj1 ;
	Obj1.insert("Ali" , 90 );
	Obj1.insert("Rhmad" , 44 );
	Obj1.insert("Ruba" , 103 );
	Obj1.insert("Majd" , 77 );
	Obj1.insert("Huda" , 85 );
	Obj1.insert("Kamel" ,39 );
	Obj1.insert("Ola" , -5 );
	Obj1.insert("Eman" , 90 );
	

	return 0 ;
}


我收到此错误
LINK:警告LNK4081:磁盘空间不足;以非增量方式链接


I get this error
LINK : warning LNK4081: insufficient disk space; linking nonincrementally

推荐答案

这里有两件事:
There are a couple of things here:
LINK : warning LNK4081: insufficient disk space; linking nonincrementally

意味着您应该认真检查您有多少磁盘空间-如果无法链接该磁盘空间,则表明运行速度非常快-否则您的软件混乱了,可能需要重新安装.

其次,您将不会获得任何输出-除非出现问题.
您的主函数创建了一个链表,向其中添加了项并退出-它不会尝试输出任何东西,据我所知,插入函数仅在出现问题时才输出任何东西.

顺便说一句:整理您的缩进.在再次发布之前对其进行修复,这样很容易阅读您的代码-对我们来说它更简单,对您来说也更简单!

Means you should seriously check how much disk space you have - if it can''t link that, then you are running out very fast - or your software is messed up and may need a re-install.

Secondly, you won''t get any output - unless something goes wrong.
You main function creates a linked list, adds items to it and exits - it doesn''t try to output anything and as far as I can see, the insert function only outputs anything if there is a problem.

BTW: Sort out your indentation. Fix it up before you post again so it is easy to read your code - it makes it simpler for us, and simpler for you!


驱动器G上的空间:

驱动器G:有多少可用磁盘空间?
It looks like you''re running out of disk space on drive G:

How much free disk space does drive G: have?


这篇关于请检查我的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆