Click here to Skip to main content
15,886,963 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to implement such such a gradient path like a ring? Pin
Richard MacCutchan3-Mar-13 22:00
mveRichard MacCutchan3-Mar-13 22:00 
GeneralRe: How to implement such such a gradient path like a ring? Pin
kcynic4-Mar-13 14:18
kcynic4-Mar-13 14:18 
GeneralRe: How to implement such such a gradient path like a ring? Pin
Richard MacCutchan4-Mar-13 22:50
mveRichard MacCutchan4-Mar-13 22:50 
QuestionTab key and delete key is not working in win32 browser control Pin
venkatesh528673-Mar-13 18:22
venkatesh528673-Mar-13 18:22 
AnswerRe: Tab key and delete key is not working in win32 browser control Pin
Richard MacCutchan3-Mar-13 21:58
mveRichard MacCutchan3-Mar-13 21:58 
GeneralMessage Closed Pin
3-Mar-13 22:18
venkatesh528673-Mar-13 22:18 
GeneralRe: Tab key and delete key is not working in win32 browser control Pin
Richard MacCutchan3-Mar-13 23:01
mveRichard MacCutchan3-Mar-13 23:01 
Questionadd element to array c++ Pin
Eshoula Aswomwe3-Mar-13 18:10
Eshoula Aswomwe3-Mar-13 18:10 
Hi guys please I need your help to do a little code at the green comment line in order to do this:


when I try to add new element to an array

Java
4   56    7    10



like 100 at 1 index position

will do this

Java
4   100    7    10  56



it should be like this :

Java
4   100   56   7    10  


so the problem is i have to use swap making swap variable take value and them move the rest on order to make like this

Java
4   100   56   7    10  




Java
  #include<iostream  >
 
using namespace std;
void printarray(int  [], int,int  );
void gradefull( int [],int ,int&);

void add(int [],int ,int) ;
void main(){

	int * gradeArray;
	int g;
	
	int elmentnumber=0;
	cout<<endl;
	cout << "\tEnter the number  of elemetn for the array: " ;
	cin>>g;

	gradeArray=new int[g];

	gradefull(gradeArray,g,elmentnumber);
 
	cout << endl  ;
	printarray(gradeArray,g,elmentnumber);
	
	cout << endl<< endl  ;
	cout<<"Adding New Element:"<<endl<<endl;
	add(  gradeArray , elmentnumber,g);
 
	cout << endl<< endl ;
	system("pause");
}


void gradefull( int gradeArray[],int g,int & elmentnumber ){
	cout<<endl; 
	for ( int i=0;i<g; i++ ){
	int input;
		cout << "please insert the element #<"<< i<<">: ";
		cin>>input;
		gradeArray[i]=input;

		elmentnumber++;
	}

}

void printarray(int gradeArray[], int g,int elmentnumber){
for ( int i=0;i<g; i++ ){
	
		cout<<"\t"<<gradeArray[i] <<" ";

	}	
cout<<endl;
		cout<<endl <<"\tYou entred <"<<elmentnumber << "> elments";
	
}

 
void add(int gradeArray [],int  elmentnumber,int g ){
	 
	int temp;
	  elmentnumber++;
	  int newinput;
		int indix;	
		 
		cout<<endl;
	  cout<<"  Please Enter the postion indix  for the new element: ";
	  cin>>indix;
	  while((indix>elmentnumber)||(indix==elmentnumber)){
	  cout<<"  Please Enter the postion indix  for the new element: ";
	  cin>>indix;
	  }
	   
	   

	 for ( int i=0;i<elmentnumber; i++ ){
	 
		 if ( i==indix){
			 temp=gradeArray[i];
			 cout<<endl<<"\tEnter the new element number: ";
		  cin>>newinput;
		gradeArray[i]=newinput;
		 }
	  
	 } cout<<endl;
	 cout<<"  The new Array after Adding the New element: "<<endl<<endl;
	 if (indix<g){
	  gradeArray[elmentnumber-1]=temp ;
	 }


// here where you should start to fix below :

	 for ( int i=0;i<elmentnumber; i++ ){ 
	  cout<<"\t"<<gradeArray[i] <<" ";
	 }

	    

}


modified 4-Mar-13 5:21am.

QuestionRe: add element to array c++ Pin
CPallini3-Mar-13 21:52
mveCPallini3-Mar-13 21:52 
AnswerRe: add element to array c++ Pin
Richard MacCutchan3-Mar-13 21:57
mveRichard MacCutchan3-Mar-13 21:57 
GeneralRe: add element to array c++ Pin
Eshoula Aswomwe3-Mar-13 23:23
Eshoula Aswomwe3-Mar-13 23:23 
GeneralRe: add element to array c++ Pin
Richard MacCutchan3-Mar-13 23:29
mveRichard MacCutchan3-Mar-13 23:29 
GeneralRe: add element to array c++ Pin
Eshoula Aswomwe3-Mar-13 23:38
Eshoula Aswomwe3-Mar-13 23:38 
GeneralRe: add element to array c++ Pin
Richard MacCutchan4-Mar-13 0:07
mveRichard MacCutchan4-Mar-13 0:07 
Questionhow to find 80 port is in use or not Pin
venkatesh528672-Mar-13 22:43
venkatesh528672-Mar-13 22:43 
AnswerRe: how to find 80 port is in use or not Pin
Garth J Lancaster2-Mar-13 23:13
professionalGarth J Lancaster2-Mar-13 23:13 
QuestionRe: how to find 80 port is in use or not Pin
David Crow3-Mar-13 10:33
David Crow3-Mar-13 10:33 
AnswerRe: how to find 80 port is in use or not Pin
Garth J Lancaster3-Mar-13 10:43
professionalGarth J Lancaster3-Mar-13 10:43 
AnswerRe: how to find 80 port is in use or not Pin
«_Superman_»3-Mar-13 14:43
professional«_Superman_»3-Mar-13 14:43 
QuestionLooking for good example for CMFCPropertyGridCtrl . Pin
oleg631-Mar-13 6:14
professionaloleg631-Mar-13 6:14 
AnswerRe: Looking for good example for CMFCPropertyGridCtrl . Pin
«_Superman_»1-Mar-13 16:31
professional«_Superman_»1-Mar-13 16:31 
QuestionMFC Programming Pin
Unque28-Feb-13 22:50
Unque28-Feb-13 22:50 
AnswerRe: MFC Programming Pin
Richard MacCutchan1-Mar-13 0:40
mveRichard MacCutchan1-Mar-13 0:40 
GeneralRe: MFC Programming Pin
Unque5-Mar-13 22:50
Unque5-Mar-13 22:50 
AnswerRe: MFC Programming Pin
Captain Price1-Mar-13 4:06
professionalCaptain Price1-Mar-13 4:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.