Ксю » 11 апр 2008, 13:18
Пасибо ОГРОМНОЕ!!!
единственно ошибочка у меня где-то...наверно в поиске не могу сообразить...
#include<iostream.h>
#include<conio.h>
#include<windows.h>
//---------------------------------------------------------------------------
const int n=3;
const int m=5;
const N=5;
char StrBuff[200];
struct Zakaz
{
int kod;
char tovar[21];
int cena;
};
Zakaz A[5];
void Input(Zakaz A[],int N);
void InitData(int a[][m], int , int) ;
void OutPut (int a[][m], int , int);
float vvod_summ(float s[]);
void poisk(Zakaz A[],float s[]);
int Mas[n][m];
int i,j;
float s[5];
void main(void)
{
Zakaz A[5];
Input(A,N);
vvod_summ(s);
InitData(Mas,n,m);
OutPut(Mas,n,m);
CharToOem("Вы можете купить: ", StrBuff);
cout<<StrBuff<<endl;
poisk(A, s);
getch();
}
void Input (Zakaz A[], int N)
{
CharToOem("Введите наименование бытовой техники", StrBuff);
cout<<StrBuff<<endl;
for (int i=0; i<N; i++)
{
CharToOem(" Введите код ", StrBuff); cout<<'\t'<< StrBuff;
cin>>A.kod;
CharToOem("Введите наименование товара ", StrBuff); cout<<'\t'<<StrBuff;
cin>> A.tovar;
CharToOem("Введите цену товара ", StrBuff); cout<<'\t'<<StrBuff;
cin>> A.cena;
}
}
void InitData(int a[][m], int rows, int cols)
{ randomize();
for(int i = 0; i < rows; i++)
for(int j = 0; j < cols; j++)
a[j] = random(5) + 1;
}
void OutPut (int a[][m], int rows, int cols)
{
CharToOem("Коды бытовой техники: ", StrBuff);
cout << StrBuff << endl;
for(int i =0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{ cout.width(5);
cout << a[j];
}
cout << endl;
}
}
float vvod_summ(float s[])
{
CharToOem("Введите сумму денег выделенную на каждой базе: ", StrBuff);
cout<<StrBuff<<endl;
for(int i=0;i<n;i++)
cin>>s;
// return s;
}
void poisk(Zakaz A[], float s[])
{
for(int i=0; i<m;i++)
{
if(A.cena<s)
{
cout<<'\t'<<A.tovar;
s[i]=s[i]-A[i].cena;
}
}
}
подскажите, пжалуста
Пасибо ОГРОМНОЕ!!!
единственно ошибочка у меня где-то...наверно в поиске не могу сообразить...
#include<iostream.h>
#include<conio.h>
#include<windows.h>
//---------------------------------------------------------------------------
const int n=3;
const int m=5;
const N=5;
char StrBuff[200];
struct Zakaz
{
int kod;
char tovar[21];
int cena;
};
Zakaz A[5];
void Input(Zakaz A[],int N);
void InitData(int a[][m], int , int) ;
void OutPut (int a[][m], int , int);
float vvod_summ(float s[]);
void poisk(Zakaz A[],float s[]);
int Mas[n][m];
int i,j;
float s[5];
void main(void)
{
Zakaz A[5];
Input(A,N);
vvod_summ(s);
InitData(Mas,n,m);
OutPut(Mas,n,m);
CharToOem("Вы можете купить: ", StrBuff);
cout<<StrBuff<<endl;
poisk(A, s);
getch();
}
void Input (Zakaz A[], int N)
{
CharToOem("Введите наименование бытовой техники", StrBuff);
cout<<StrBuff<<endl;
for (int i=0; i<N; i++)
{
CharToOem(" Введите код ", StrBuff); cout<<'\t'<< StrBuff;
cin>>A[i].kod;
CharToOem("Введите наименование товара ", StrBuff); cout<<'\t'<<StrBuff;
cin>> A[i].tovar;
CharToOem("Введите цену товара ", StrBuff); cout<<'\t'<<StrBuff;
cin>> A[i].cena;
}
}
void InitData(int a[][m], int rows, int cols)
{ randomize();
for(int i = 0; i < rows; i++)
for(int j = 0; j < cols; j++)
a[i][j] = random(5) + 1;
}
void OutPut (int a[][m], int rows, int cols)
{
CharToOem("Коды бытовой техники: ", StrBuff);
cout << StrBuff << endl;
for(int i =0; i < rows; i++)
{
for(int j = 0; j < cols; j++)
{ cout.width(5);
cout << a[i][j];
}
cout << endl;
}
}
float vvod_summ(float s[])
{
CharToOem("Введите сумму денег выделенную на каждой базе: ", StrBuff);
cout<<StrBuff<<endl;
for(int i=0;i<n;i++)
cin>>s[i];
// return s[i];
}
void poisk(Zakaz A[], float s[])
{
for(int i=0; i<m;i++)
{
if(A[i].cena<s[i])
{
cout<<'\t'<<A[i].tovar;
s[i]=s[i]-A[i].cena;
}
}
}
подскажите, пжалуста