Skip to content

Instantly share code, notes, and snippets.

@zmack
Created April 27, 2010 15:00
Show Gist options
  • Save zmack/380827 to your computer and use it in GitHub Desktop.
Save zmack/380827 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int n,i;
struct biblioteka
{
char ime[40];
int shifer;
double price;
int broi;
}a[100];
void vuvejdane()
{
do
{
cout<<"Obsht broj knigi : ";
cin>> n;
} while (n<0||n>100);
for (int i=0;i<n;i++)
{
cin.ignore();
cout<<"Vuvedete zaglawie na knigata : ";
cin.getline(a[i].ime,40);
cout<<"Vuvedete shifar kym knigata : ";
cin>> a[i].shifer;
cout<<"Vuvedete cena na knigata : ";
cin>>a[i].price;
cout<<"Vuvedete broj na syotvetnata kniga : ";
cin>>a[i].broi;
}
}
void izvejdane()
{
cout << endl;
for (int i = 0; i < n; i++)
{
cout<<setw(20)<<a[i].ime<<setw(6)<<a[i].shifer<<setw(6)<<a[i].price<<setw(6)<<a[i].broi<<endl;
}
cout << endl;
}
void izchislenie()
{
double max=0;
for (int i=0;i<=n;i++)
{
max+=(a[i].price)*a[i].broi;
}
cout<<"Obshta suma na knigite v nalichnost e :"<<max<<endl;
}
void makcena()
{
double max,result;
max=a[0].price;
result=a[i].price;
for (int i=0;i<n;i++)
{
result=a[i].price;
max=a[0].price;
if (result>max) max=a[i].price;
}
cout<<"Nai visoka cena za kniga e :"<<max<<endl;
}
int main()
{
vuvejdane();
izvejdane();
izchislenie();
makcena();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment