NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#include <iostream>
#include <cmath>
/*
5
5 5 5 4 5
3 4 1 2 1
4 4 4 4 2
2 3 4 5 2
5 4 5 4 5
*/

using namespace std;

/*Ez a resz mehetne diak.h fajlba (plusz ifndef, define), de nem a mesteren!*/
struct Diak {
int jegy[5];
int db1() //megszamlalas
{
int db = 0;
for (int i = 0; i < 5; i++)
if(jegy[i] == 1)
db++;
return db;
}

bool jo(); //kívül megírva

double tortresz() //osszegzes
{
double atl = 0.0;
for(int i = 0; i < 5; i++)
atl +=jegy[i];
atl /= 5;
return atl - floor(atl);
}

int maradek(); //kint megírva

bool feles(); //kint megírva
};

/*Ez a resz mehetne diak.cpp fajlba, de nem a mesteren!*/
bool Diak::jo() //eldontes
{
int db = 0;
int i;
for (i = 0; i < 5 && db < 2; i++)
if(jegy[i] == 1)
db++;
return db < 2; //jo, ha a végére is csak max 1 elégtelenje van
// return i == 5 hibás eredményt ad, ha az utolsó érték 1.
// T(i)-ben nincs i, ezért lehet if (db < 2 && i <5) is.
}

int Diak::maradek() //osszegzes
{
int sum = 0;
for(int i = 0; i < 5; i++)
sum += jegy[i];
return sum % 5;
}

bool Diak::feles() //összegzes + feltetel
{
int sum = 0;
for(int i = 0; i < 5; i++)
sum += jegy[i];
sum %=5;
return (sum == 2 || sum == 3);
//double atlag-os megoldás pontatlan (mesteren 90/100)
}

/*Ha a Diak másik fájban ban, akkor ide kell #include "diak.h", de nem a mesteren!*/

const int maxN = 100;
Diak csoport[maxN];

int bukofelelo(int N) //kereses, globalis tombon
{
int i;
for(i = 0; i < N && csoport[i].jo(); i++)
;
return i < N ? i : -1;
}

int felesfelelo(Diak tomb[], int N) //kereses, atvett (vagy globalis) tombon
{
int i;
for(i = 0; i < N && !tomb[i].feles(); i++)
;
return i < N ? i : -1;
}

int main()
{
//beolvasás
cerr << "a csoport letszama: ";
int N;
cin >> N;
cerr << "jegyek beolvasasa" << endl;
for (int i = 0; i < N; i++)
for (int j = 0; j < 5; j++)
cin >> csoport[i].jegy[j];
for (int i = 0; i < N; i++) {
for (int j = 0; j < 5; j++)
cerr << csoport[i].jegy[j] << 't';
cerr << endl;
}

int felelo = -1;
//feldolgozás
/*
for(int i = 0; felelo == -1 && i < N; i++)
if(csoport[i].db1() >= 2) //db1 végignézi. Minek?
felelo = i;

for(int i = 0; felelo == -1 && i < N; i++)
if(0.4 <= csoport[i].tortresz() && csoport[i].tortresz() <= 0.6) //nem jo 0.4 == tortresz, mert double. 0.6-ra sem.
//if(0.39 < csoport[i].tortresz() && csoport[i].tortresz() <= 0.59) //nem szep, magikus szam
//if(2 <= csoport[i].maradek() && csoport[i].maradek() <= 3) // egészek!! de minek most a <>?
//if(csoport[i].maradek() == 2 || csoport[i].maradek() == 3)
felelo = i;
if(felelo == -1)
felelo = 0;
*/
//inkább így
/*
int i;
for(i = 0; i < N && csoport[i].jo(); i++)
;
if (i < N)
felelo = i;

if (felelo == -1) {
for(i = 0; i < N && !csoport[i].feles(); i++)
;
if(i<N)
felelo = i;
}
if(felelo == -1)
felelo = 0;
*/
//vagy inkább így

felelo = bukofelelo(N);
if (felelo == -1)
felelo = felesfelelo(csoport, N);
if(felelo == -1)
felelo = 0;


//kiírás
cerr << "eredmeny: ";
cout << felelo + 1 << endl;
return 0;
}

     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.