Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > IT форум > Помощь студентам
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 25.02.2014, 16:25   #1
Валера1984
Пользователь
 
Регистрация: 10.02.2014
Сообщений: 14
По умолчанию Как правильно записать условие С++

Программа должна выводить всех Forward которые играют в основном составе Main.
Kак записать условие ?
Код:
void find_fav()
    {
        List *node = head->next;
        List *current_node = head;
        
 
        while(node != NULL)
        {
            if (node->sport.Sostav == current_node && node->sport.MestoVkomande=="Forward") 
      
            
        
            current_node = node;
            node = node->next;
            
            
        }
        
          printf("%20s!%2d.%2d.%4d \n",current_node->sport.fio,current_node->sport.d_birth.day,current_node->sport.d_birth.month,current_node->sport.d_birth.year);

Программа целиком
Код:
#include"stdafx.h"
#include"iostream"
#include"conio.h"
 
using namespace std;
 
struct Data         
    {
        unsigned day;       
        unsigned month;     
        unsigned year;
    };
 
struct T_sport
    {
        char fio[40];
        Data d_birth;
        unsigned v_CSKA ;
        char MestoVkomande [20];
        char Sostav [20];
        
}; 
 
struct List
{
    T_sport sport;
    List *next;
};
 
class main_n
{
private:
    List *head;
public:
    main_n()
    {
        head = NULL;
        List *node1 = new List;
        T_sport a ={"Ivanov I. I.",3,1,1984,2000,"Defender","Reserve"}; 
        node1->sport = a;
        node1->next = head;
        head = node1;
        List *node2 = new List;
        T_sport b ={"Petrov A.A.",8,12,1987,2002, "Forward","Main"};
        node2->sport = b;
        node2->next = head;
        head = node2;
    }
 
    void insert_before()
    {
        T_sport a; 
    char c;
    cout<<endl<<"Enter data person\n";
    cout<<" fio ";
    cin.getline(a.fio,40);
    cout<<endl<<"Enter date of birthday: \n";
    cout<<" day (1-31) ";
    cin>>a.d_birth.day;
    cin.get(c);
    cout<<" month (1-12)";
    cin>>a.d_birth.month;
    cin.get(c);
    cout<<" year ";
    cin>>a.d_birth.year;
    cin.get(c);
    cout<<" v_CSKA ";
    cin>>a.v_CSKA;
    cin.get(c);
    cout<<" MestoVkomande ";
    cin.getline(a.MestoVkomande,20);
    cout<<" Sostav ";
    cin.getline(a.Sostav,20);
 
 
        List *node = new List;
        node->sport = a;
        node->next = head;
        head = node;
    }
 
    void print_list()
    {
        printf("[ ");
        List *node = head;
        while(node != NULL)
        {
         printf("%20s ! %2d.%2d.%4d ! %4d ! %15s ! %15s\n",node->sport.fio,node->sport.d_birth.day,node->sport.d_birth.month,node->sport.d_birth.year,node->sport.v_CSKA,node->sport.MestoVkomande,node->sport.Sostav);
         node = node->next;
        }
 
        printf("]\n");
    }
 
    void find_fav()
    {
        List *node = head->next;
        List *current_node = head;
        
 
        while(node != NULL)
        {
            if (node->sport.Sostav == current_node && node->sport.MestoVkomande=="Forward") 
      
            
        
            current_node = node;
            node = node->next;
            
            
        }
        
          printf("%20s!%2d.%2d.%4d \n",current_node->sport.fio,current_node->sport.d_birth.day,current_node->sport.d_birth.month,current_node->sport.d_birth.year);
 
        
    }
};
 
int main()
{
    
    main_n f;
    for(int i = 2; i < 5; i++)
    {   
        f.insert_before();
    };
    cout <<"\nlist of structs\n!      fio           !  facul\'tet !  kurs   !\n";
    f.print_list();
    f.find_fav();
    _getch();
 
    return 0;
}
Валера1984 вне форума Ответить с цитированием
Старый 25.02.2014, 16:33   #2
BDA
МегаМодератор
СуперМодератор
 
Аватар для BDA
 
Регистрация: 09.11.2010
Сообщений: 7,289
По умолчанию

strcmp
Пишите язык программирования - это форум программистов, а не экстрасенсов. (<= это подпись )
BDA вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Как правильно записать условие выборки данных из структуры (нападающих из основного состава команды) ( на C ) Валера1984 Помощь студентам 7 15.02.2014 13:34
Как правильно записать условие VP86 Общие вопросы C/C++ 7 17.09.2013 14:34
Как правильно поставить условие? hacker_007 Общие вопросы Delphi 14 20.09.2011 00:00
Как правильно поставить условиЕ. 89legend89 Microsoft Office Excel 5 07.10.2010 00:09