ANTICHAT.XYZ    VIDEO.ANTICHAT.XYZ    НОВЫЕ СООБЩЕНИЯ    ФОРУМ  
Баннер 1   Баннер 2
Antichat снова доступен.
Форум Antichat (Античат) возвращается и снова открыт для пользователей. Здесь обсуждаются безопасность, программирование, технологии и многое другое. Сообщество снова собирается вместе.
Новый адрес: forum.antichat.xyz
Вернуться   Форум АНТИЧАТ > Программирование > С/С++, C#, Delphi, .NET, Asm
   
 
 
Опции темы Поиск в этой теме Опции просмотра

Помогите разобраться с ошибками
  #1  
Старый 18.05.2009, 23:58
Аватар для Mozy
Mozy
Познающий
Регистрация: 15.03.2009
Сообщений: 77
Провел на форуме:
984248

Репутация: 73
Отправить сообщение для Mozy с помощью ICQ
По умолчанию Помогите разобраться с ошибками

Мне очень срочно надо что бы программа работала
написана на Visual С++

Код:
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <fstream>
#include <string>
#include <io.h>
using namespace std;

void my_enter(void);
void my_display(void);
void my_delete_record(void);
void my_edit(void);
void my_sort(void);

 char filename[100];

struct rabochi
{
    char fio[24];
    int Monday,Tuesday,Wednesday,Thursday,Friday,Saturday;
    int nomer;
    int sr;
}r[100];

int main()
{
        char c=0;
        cout << "Enter filename" << endl;
        cin >> filename;
        system("cls");
        while(c!='q')
        {
                cout<<"1 - Enter new."<<endl;
                cout<<"2 - Display."<<endl;
                cout<<"3 - Delete record."<<endl;
                cout<<"4 - Edit Record."<<endl;
                cout<<"5 - Problem part."<<endl;
                cout<<"q - Quit."<<endl;
                cin>>c;
                system("cls");
                switch(c)
                {
                        case '1':
                            my_enter();
                            break;
                        case '2':
                            my_display();
                            break;
                        case '3':
                            my_delete_record();
                            break;
                        case '4':
                            my_edit();
                            break;
                        case '5':
                            my_sort();
                            break;
                        default:
                            break;
                }      
		}
}

void my_enter(void)
{
char vib='n';
int i=0;

fstream file;
file.open(filename, ios::app);
        
        if (!file)
        {
            cerr<<"TRY OPEN FILE \""<<filename<<"\" GET ERROR!"<<endl;
            
        }

        do{
        i++;
        r[i].nomer=i;
        cout<<"Enter FIO: "<<endl;
		cin >> r[i].fio;
        cout<<"Enter the amount of detail collected on Monday"<<endl;
        cin>>r[i].Monday;
        cout<<"Enter the amount of detail collected on Tuesday"<<endl;
        cin>>r[i].Tuesday;
        cout<<"Enter the amount of detail collected on Wednesday"<<endl;
        cin>>r[i].Wednesday;
        cout<<"Enter the amount of detail collected on Thursday"<<endl;
        cin>>r[i].Thursday;
        cout<<"Enter the amount of detail collected on Friday"<<endl;
        cin>>r[i].Friday;
        cout<<"Enter the amount of detail collected on Saturday"<<endl;
        cin>>r[i].Saturday;

        file<<r[i].nomer<<" "<<r[i].fio<<" "<<r[i].Monday<<" "<<r[i].Tuesday<<" "<<r[i].Wednesday<<" "<<r[i].Thursday<<" "<<r[i].Friday<<" "<<r[i].Saturday<<endl;
         cout << "What's all(y/n)?" << endl;
	  	cin >> vib;
        }while(vib == 'y');

        file.close();
		
       
}
    
void my_display(void)
{
        int i=0;

        ifstream file;
        file.open(filename);
        
        if (!file)
        {
            cout<<"TRY OPEN    FILE \""<<filename<<"\"! GET ERROR!"<<endl;
         
        }

        cout <<"============================================================================\n";
        cout <<"|         FIO         |Monday|Tuesday|Wednesday|Thursday|Friday|Saturday    |\n";
        cout <<"============================================================================\n";
        while(!file.eof())
        {    
            i++;
            file>>r[i].fio>>r[i].Monday>>r[i].Tuesday>>r[i].Wednesday>>r[i].Thursday>>r[i].Friday>>r[i].Saturday;
            cout<<"|"<<setw(10)<<
            r[i].fio<<setw(10)<<
            "|"<<setw(4)<<
            r[i].Monday<<setw(4)<<
            "|"<<setw(4)<<
            r[i].Tuesday<<setw(4)<<
            "|"<<setw(4)<<
            r[i].Wednesday<<setw(4)<<
            "|"<<setw(4)<<
            r[i].Thursday<<setw(4)<<
            "|"<<setw(4)<<
            r[i].Friday<<setw(4)<<
            "|"<<setw(4)<<
            r[i].Saturday<<setw(4)<<
            "|\n";
            cout << "=========================================================================\n";
        }
        file.close();
		
       
}

void my_delete_record(void)
{
    int i=0,j;
    char del='n';

    fstream file;
    file.open(filename, ios::app);
        
        if (!file)
        {
            cerr<<"TRY OPEN FILE \""<<filename<<"\" GET ERROR!"<<endl;
           
		}

        do{
    cout << "Enter number of worker" << endl;
    cin >> i;
    
    file >> r[i].nomer>>r[i].fio>>r[i].Monday>>r[i].Tuesday>>r[i].Wednesday>>r[i].Thursday>>r[i].Friday>>r[i].Saturday;
    
    r[i].nomer=' ';
	for (j=0;j<=23;j++){
		r[i].fio[j]=' ';}
    r[i].Monday=' ';
    r[i].Tuesday=' ';
    r[i].Wednesday=' ';
    r[i].Thursday=' ';
    r[i].Friday=' ';
    r[i].Saturday=' ';

    file << r[i].nomer 
		 << r[i].fio 
		 << r[i].Monday
		 << r[i].Tuesday
		 << r[i].Wednesday
		 << r[i].Thursday
		 << r[i].Friday
		 << r[i].Saturday;

    cout << "Record deleted" << endl;
    cout << "What's all?(y/n)" << endl;
    }while(del == 'y');

     file.close();
	
}

void my_edit(void)
{    
	int i=0;
	char del='n';
    
    fstream file;
    file.open(filename, ios::app);
        
        if (!file)
        {
            cerr<<"TRY OPEN FILE \""<<filename<<"\" GET ERROR!"<<endl;
             
		}

        do{
    cout << "Enter number of worker" << endl;
    cin >> i;
    
    file >>r[i].nomer>>r[i].fio>>r[i].Monday>>r[i].Tuesday>>r[i].Wednesday>>r[i].Thursday>>r[i].Friday>>r[i].Saturday;
    
    cout << r[i].nomer<<" "<<r[i].fio<<" "<<r[i].Monday<<" "<<r[i].Tuesday<<" "<<r[i].Wednesday<<" "<<r[i].Thursday<<" "<<r[i].Friday<<" "<<r[i].Saturday;

        cout<<"Enter FIO: "<<endl;
        cin>>r[i].fio;
        cout<<"Enter the amount of detail collected on Monday"<<endl;
        cin>>r[i].Monday;
        cout<<"Enter the amount of detail collected on Tuesday"<<endl;
        cin>>r[i].Tuesday;
        cout<<"Enter the amount of detail collected on Wednesday"<<endl;
        cin>>r[i].Wednesday;
        cout<<"Enter the amount of detail collected on Thursday"<<endl;
        cin>>r[i].Thursday;
        cout<<"Enter the amount of detail collected on Friday"<<endl;
        cin>>r[i].Friday;
        cout<<"Enter the amount of detail collected on Saturday"<<endl;
        cin>>r[i].Saturday;

    file << r[i].nomer
		 << r[i].fio
		 << r[i].Monday
		 << r[i].Tuesday
		 << r[i].Wednesday
		 << r[i].Thursday
		 << r[i].Friday
		 << r[i].Saturday;

    cout << "Record edited" << endl;
    cout << "What's all?(y/n)" << endl;
    }while(del == 'y');

     file.close();
  
}


void my_sort(void)
{
    int i=0;
    int max=0;
    
    fstream file;
    file.open(filename, ios::app);
        
        if (!file)
        {
            cerr<<"TRY OPEN FILE \""<<filename<<"\" GET ERROR!"<<endl;
           
        }

        while(! file.eof()){
            i++;

            file>>r[i].nomer>>r[i].fio>>r[i].Monday>>r[i].Tuesday>>r[i].Wednesday>>r[i].Thursday>>r[i].Friday>>r[i].Saturday;
            
            r[i].sr=(r[i].Monday+r[i].Tuesday+r[i].Wednesday+r[i].Thursday+r[i].Friday+r[i].Saturday)/6;
            
            if(r[i].sr > max){
                max=r[i].sr;
            }
            }
            i=0;

        while(! file.eof()){
            i++;
            
            file>>r[i].nomer>>r[i].fio>>r[i].sr>>r[i].Monday>>r[i].Tuesday>>r[i].Wednesday>>r[i].Thursday>>r[i].Friday>>r[i].Saturday;

            if (r[i].sr == max)
                exit(1);
        }

        if(r[i].Monday>r[i].Tuesday && r[i].Monday>r[i].Wednesday && r[i].Monday>r[i].Thursday && r[i].Monday>r[i].Friday && r[i].Monday>r[i].Saturday){
            cout << "More details of all made " << r[i].fio << " a day when he reached the highest productivity is Monday";
        }
        if(r[i].Tuesday>r[i].Monday && r[i].Tuesday>r[i].Wednesday && r[i].Tuesday>r[i].Thursday && r[i].Tuesday>r[i].Friday && r[i].Tuesday>r[i].Saturday){
            cout << "More details of all made " << r[i].fio << " a day when he reached the highest productivity is Tuesday";
        }
        if(r[i].Wednesday>r[i].Monday && r[i].Wednesday>r[i].Thursday && r[i].Wednesday>r[i].Friday && r[i].Wednesday>r[i].Saturday){
            cout << "More details of all made " << r[i].fio << " a day when he reached the highest productivity is Wednesday";
        }
        if(r[i].Thursday>r[i].Monday && r[i].Thursday>r[i].Wednesday && r[i].Thursday>r[i].Friday && r[i].Thursday>r[i].Saturday){
            cout << "More details of all made " << r[i].fio << " a day when he reached the highest productivity is Thursday";
        }
        if(r[i].Friday>r[i].Monday && r[i].Friday>r[i].Wednesday && r[i].Friday>r[i].Thursday && r[i].Friday>r[i].Saturday){
            cout << "More details of all made " << r[i].fio << " a day when he reached the highest productivity is Friday";
        }
        if(r[i].Saturday>r[i].Monday && r[i].Saturday>r[i].Wednesday && r[i].Saturday>r[i].Thursday && r[i].Saturday>r[i].Friday){
            cout << "More details of all made " << r[i].fio << " and day when he reached the highest productivity is Saturday";
        }
	
		
}
А я почти разобрался во всём

Последний раз редактировалось Mozy; 21.05.2009 в 22:28..
 
Ответить с цитированием
 



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Помогите разобраться в коде фейка! andruhasms Разное - Покупка, продажа, обмен 7 15.01.2009 00:48
Помогите разобраться.... DarkMist PHP, PERL, MySQL, JavaScript 2 04.01.2009 03:15
Помогите разобраться с угоном Аськи seeattact ICQ 5 17.01.2006 03:14
Помогите разобраться с методом описанным на этом сайте BARMALEY E-Mail 3 30.05.2005 12:18



Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
 


Быстрый переход




ANTICHAT.XYZ