11-07-2006, 10:57
|
|
|
חבר מתאריך: 11.07.06
הודעות: 4
|
|
C++ דחוף
בבקשה תעשו את זה דחוף!
Give the full explanation of following C++ program and insert comment to every line:
#include <iostream.h>
#include <conio.h>
#include <string.h>
template <class T> void sort (T * list, int n) {
int a, b; T temp;
for (a=1; a<n; a++) {
for (b=n-1; b>=a; b--) {
if (list[b-1] > list[b]) {
temp = list[b-1];
list[b-1] = list[b];
list[b] = temp;}}}}
struct person {
char name[40];
unsigned long phone;
friend int operator > (person & a, person & b);
};
int operator > (person & a, person & b) {
return stricmp (a.name, b.name) > 0;}
void main () {
int i;
float alpha[10] = {5.8, 9.3, 0.2, 2.7, 3.5, 9.5, 1.1, 4.3, 7.4, 2.3};
sort (alpha, 10);
for (i=0; i<10; i++) cout << alpha[i] << " ";
cout << "\n\n";
person artists[10] = {
{"Madonna", 10203040}, {"Police", 33131448},
{"George Michael", 45687518}, {"Michael Jackson", 11223344},
{"Piotr Tchaikovsky", 73284855}, {"Kurt Cobain", 66666666},
{"Spice Girls", 18345842}, {"Jon Bon Jovi", 43581572},
{"LL Cool J", 98765432}, {"Beatles", 33336666}
};
sort (artists, 10);
for (i=0; i<10; i++) {
cout << "\n" << artists[i].name << " " << artists[i].phone;}
getch();}
Write C++ program that plots the graph of function in interval [-1, 1] and computes its derivative.
|