Цитата(Soad79 @ 24.3.2009, 19:05 ) | | Я написал вот это. Правильно ли начало. И не могли бы мне помочь дописать до конца. |
Лови заготовку
| Код | #include <iostream>
#define LESSON_COUNT 3
const char * LessonName[LESSON_COUNT]= { "Lesson0", "Lesson1", "Lesson2"}; // названия уроков
const char * RateName[] = { "", "one", "two", "three", "four", "five"}; // названия оценок
struct Student { int Rate[LESSON_COUNT]; };
int main () { Student st;
st.Rate[0] = 5; // Lesson0 is 5; st.Rate[1] = 3; // Lesson1 is 3; st.Rate[2] = 4; // Lesson2 is 4;
for (int i=0; i<LESSON_COUNT; ++i) std::cout << LessonName[i] <<" is " <<st.Rate[i]<<std::endl; // Предваритель
int min = 0; int max = 0; for (int i=1; i<LESSON_COUNT; ++i) { if (st.Rate[i]<st.Rate[min]) min =i; if (st.Rate[i]>st.Rate[max]) max= i; }
std::cout << "Min Rate is " <<st.Rate[min]<<" in "<<LessonName[min]<<std::endl; std::cout << "Max Rate is " <<st.Rate[max]<<" in "<<LessonName[max]<<std::endl;
// Альтернативный вариант (вывод оценки по имени ) // std::cout << "Min Rate is " <<RateName[st.Rate[min]]<<" in "<<LessonName[min]<<std::endl; // std::cout << "Max Rate is " <<RateName[st.Rate[max]]<<" in "<<LessonName[max]<<std::endl;
system("pause"); return(0); }
|
|