hello,can someone help me?
I must make a program which contains:
Deck (the data in it must be integer(numbers)),(if possible,in header file).
Sort the elements by the method of Shell
Find the elements that can be divided by 5, and smaller then the largest number that can be divided by 7.
The results(if possible in header file).
Function main() with menu of the functions, and checking the status of the data.
I understand this well,but I can't do it. I've tried so long and I just can't.
You are my last hope.
Thanks

[code=language]
#include<iostream.h>
#include<conio.h>
void push_l(int n);
void push_r(int n);
void shellsort(int a[];int left;int right);
struct deck1{
int key;
deck1*next;
}
*left=NULL;
*right=NULL;
void main(){
int num;
do{
int numb;
cout<<"Menu:\n";
cout<<"1-Add elements(left)\n";
cout<<"2-Add elemens(right)\n";
cout<<"3-Find elements\n";
cout<<"4-Sort\n";
cout<<"5-Results\n";
cout<<"6-End\n";
cout<<"Select:";
cin<<num;
switch(num){
case(1):
case(2):
out<<"Add elements:";
cin>>numb;
if(num 1)
push_l(numb);
else
push_r(numb);
break;
case(3):{
if(numb%5&&numb<(i don't know how to do this)
cout<<numb<<"\n";
getche();
}
else{
cout<<"There's no such number!\n";
getch();
}
break;
case(4):
cout<<numb.shelsort()<<"\n";
break;
case(5):
cout<<numb<<\n;
while(num!6);
break;
}
void push_l(int n){
deck1 *p;
p=left;
left=new deck1;
left->key=n;
left->next*p;
if(right==NULL){
right=left;}
}
void push_r(int n){
deck1*p;
p=right;
right=new elem;
right->key=n;
right->next=NULL;
if(left==NULL)
left=right;
else
p->next=right;
}
void shellsort(int a[];int left;int right){
int h;
for(h=1;h<=(right-left)/9;
h=3*h+1;
for(;h>0;h/=3)
for(int i=left+h;i<=right;i++){
int j=i;
int v=a[i];
while(j)=left+h&&v<a[j-h]){
a[j]=a[j-h];
j-=h;}
a[j]=v;
}
}}}

Any particular reason why we would want to look at that unindented mess?

What is line 10, and 11?
main() must be able to return zero, and there really is no file called <iostream.h>, look it up.
Is getche() a typo, or do you really need it?
Biggest question: is your tab, or space bar broken? You'll never be able to fix something no-one can read, I just stop after several lines, and scrolled through the mess.

I''m so sorry about the mess!
I hope this is better:

#include<stdafx.h>
#include<iostream.h>
#include<conio.h>
void push_l(int n);
void push_r(int n);
void shellsort(int a[];int left;int right);
struct elem{
	int key;
	elem *next;
}
*left=NULL;
*right=NULL;
int main(){
	int num;
	do{
		int numb;
		cout<<"Menu:\n";
		cout<<"1-Add elements(left)\n";
		cout<<"2-Add elemens(right)\n";
		cout<<"3-Find elements\n";
		cout<<"4-Sort\n";
		cout<<"5-Results\n";
		cout<<"6-End\n";
		cout<<"Select:";
		cin<<num;
		switch(num){
case(1):
case(2):
	cout<<"Add elements:";
	cin>>numb;
	if(num 1)
		push_l(numb);
	else
		push_r(numb);
	break;
case(3):{
	if(numb%5&&numb<(i don't know how to do smaller from divided by 7)
		cout<<numb<<"\n";
		}
else{
	cout<<"There's no such number!\n";
}
break;
case(4):
	cout<<numb.shelsort()<<"\n";
	break;
case(5):
	cout<<numb<<\n;
	while(num!6);
	break;
		}
		void push_l(int n){
			elem *p;
			p=left;
			left=new elem;
			left->key=n;
			left->next*p;
			if(right==NULL){
				right=left;}
		}
		void push_r(int n){
			elem *p;
			p=right;
			right=new elem;
			right->key=n;
			right->next=NULL;
			if(left==NULL;
			left=right;
			else
				p->next=right;
		}
		void shellsort(int a[];int left;int right){
			int h;
			for(h=1;h<=(right-left)/9;
				h=3*h+1;
				for(;h>0;h/=3)
					for(int i=left+h;i<=right;i++){
						int j=i;
						int v=a[i];
						while(j)=left+h&&v<a[j-h]){
							a[j]=a[j-h];
							j-=h;
						}
						a[j]=v;
					}
		}
	}
}

line 10 and 11 are the sides of the deck (left and right ). I made them NULL so I can add elements later.

Have you you tried compiling it, and reading the error reports? There's invalid operations, spelling mistakes, missing types, definitions where there shouldn't be, et al.
I think you need to start anew, slowly adding piece-by-piece, compiling, fixing, learning, and so on.

You also might want an IDE to help do the indenting for you, as you go along.

Actually, I find out why it was giving me no errors, I've worked over it and now I have some questions:
The shell sort will work only if I "place" the deck into massive. (I don't know how), and I don't know will be good to find the max number then to divide it with 7 and than to add something like:
num%&&num<max%7 (I'm talking about case 3), or there is some easy way to do it?
I'm having progress so far
Thanx

Actually, I find out why it was giving me no errors, I've worked over it and now I have some questions:
The shell sort will work only if I "place" the deck into massive.

Sorry... I must place the deck (deque) into array so that the shell sort will work.

Ok, I was able to correct most of the code, but I still have 10 errors.
Can someone help me now?

#include<fstream.h>
#include<iostream.h>
#include<conio.h>
void push_l(int n);
void push_r(int n);
int pop_l(int n);
int pop_r(int n);
void shell_sort(int a[],int size);
void results();
struct elem{
	int key;
	elem*next;
};
elem *left=NULL;
elem *right=NULL;
int b[100];
int sort;
void main(){
	int num;
	do{
		int numb;
		cout<<"Menu:n";
		cout<<"1-Add elements(left)\n";
		cout<<"2-Add elemens(right)\n";
		cout<<"3-Adding into array\n";
		cout<<"4-Find elements\n";
		cout<<"5-Sort\n";
		cout<<"6-Results\n";
		cout<<"7-End\n";
		cout<<"Select:\n";
		cin>>num;
		switch(num){
case(1):
	cout<<"Add elements to left:";
	while(cin>>numb){
		push_l(numb);
	}
	break;
case(2):
	cout<<"Add elements to right:";
	while(cin>>numb){
		push_r(numb);
	}
	break;
case(3):
	int k,j,i=0;
	int a[100];
	a[0]=1;
	while(left){
		pop_l(k);
		a[i]=k;
		i++;
	}
	for(j=0;j<=i;j++){
		pop_r(a[j]);
	}
	break;
case(4):
	int broj;
	int counter=-1;
	for (i=0; i<100; i++)
		if (a[i]%7==0)
			broj=a[i];
		for (i=0; i<numb; i++)
			if (a[i]<=broj)
				if (a[i]%5==0)
				{
					counter=counter++;
					b[counter]=a[i];
				}
				else
					cout<<"There's no such number!\n";
		}
		break;
case(5):
	cout<<sort=shell_sort(numb);
	break;
case(6):
	ifstream f("results.txt");
	while(pop_l(numb)&&pop_r(numb)){
		cout<<numb<<"";
	}
	while(num!=7);
	break;
	}
	void push_l(int n){
		elem *p=left;
		left=new elem;
		left->key=n;
		left->next=p;
		if(p==right)
			right=left;
	}
	void push_r(int n){
		elem *p=right;
		right=new elem;
		right->key=n;
		right->next=NULL;
		if(p)
			p->next=right;
		if(left==p)
			left=right;
	}
	int pop_l(int &n){
		elem *p;
		if(left){
			n=left->key;
			p=left;
			left=left->next;
			if(left==NULL)
				right=NULL;
			delete p;
			return 1;
		}
		else
			return 0;
	}
	int pop_r(int &n){
		elem *p;
		if(right){
			n=right->key;
			if(left==right){
				delete right;
				left=right=NULL;
			}
			else{
				p=left;
				while(p->next!=right)
					p++;
				n=right->key;
				p->next=NULL;
				delete right;
				right p;
				return 1;
			}
			else return 0;
		}
		void shell_sort(int a[],int size){
			int i,j,increment,temp;
			increment=size/2;
			while (increment>0)
			{
				for(i=increment;i<size;i++){
					j=i;
					temp=a[i];
					while((j>=increment)&&(a[j-increment]>temp)){
						a[j]=a[j-increment];
						j=j-increment;
					}
					a[j]=temp;
				}
				if(increment==2)
					increment=1;
				else 
					increment=(int)(increment/2.2);
			}
		}
	}
}

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.