Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  hjhkhjk
Language: C/C++
Code:
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

struct Ship{
    int n,t;
};
vector<Ship> dok;


int _tmain(int argc, _TCHAR* argv[])
{
    
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout);

    int N;
    scanf("%d", &N);

    for(int i=0; i<N; ++i){
        Ship ship;
        scanf("%d%d", &ship.n, &ship.t);
        dok.push_back(ship);
    }
    
//пузырькова ÑÐ¾Ñ€Ñ‚ировка
    for(int i=0; i<N-1; ++i)
        for(int j=0; j<N-i-1; ++j)
            if (dok[j].t > dok[j + 1].t){
                Ship ship = dok[j];
                dok[j] = dok[j + 1];
                dok[j + 1] = ship;
            }


    //вывод Ñ€ÐµÐ·ÑƒÐ»ÑŒÑ‚ата
    for(int i=0; i<N-1; ++i)
        printf("%d ", dok[i].n);
    printf("%d\n", dok[N-1].n);

    return 0;
}     
Comments: