Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int maxsorok=1000;
- int beolvas_egesz();
- void beolvas_matrix(const int sorok,const int oszlopok, int tomb[][maxsorok]);
- int feladat(const int sorok,const int oszlopok,int tomb[][maxsorok]);
- int main()
- {
- setlocale(LC_ALL,"hun");
- int napok;
- int orok;
- napok = beolvas_egesz();
- orok = beolvas_egesz();
- int asd[napok][maxsorok];
- beolvas_matrix(napok,orok,asd);
- int megoldas;
- megoldas=feladat(napok,orok,asd);
- cout << megoldas;
- for (int j=0;j<napok;j++) {
- for (int k=0;k<orok;k++) {
- cout << asd[j][k] << " ";
- }
- cout << endl;
- }
- return 0;
- }
- int beolvas_egesz() {
- int szam;
- cin >> szam;
- return szam;
- }
- void beolvas_matrix(const int sorok,const int oszlopok, int tomb[][maxsorok]) {
- int start[oszlopok];
- int veg[oszlopok];
- for (int i=0;i<sorok;i++) {
- cin >> start[i] >> veg[i];
- for (int j=0;j<oszlopok;j++) {
- if (j>= start[i]-1 && j<veg[i]) {
- tomb[i][j] = 1;
- }
- else {
- tomb[i][j] = 0;
- }
- }
- }
- }
- int feladat(const int sorok,const int oszlopok,int tomb[][maxsorok]) {
- bool empty;
- int i;
- for (i=0;i<oszlopok;i++) {
- empty=true;
- for (int j=0;j<sorok && empty;j++) {
- if (tomb[j][i] == 1) {
- empty = false;
- }
- }
- if(empty) {
- return i+1;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement