Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <stdlib.h>
- using namespace std;
- int main()
- {
- int N;
- string sz;
- bool hiba, hiba1;
- do
- {
- cout << "A vizsgazok szama= ";
- cin >> sz;
- N=atoi(sz.c_str());
- hiba=(N==0)&&(sz!="0");
- if(hiba)
- {
- cout << "Nem jo jelsorozatot adott." << endl;
- }
- hiba1=(N<=0);
- if(hiba1)
- {
- cout << "Nem pozitiv egeszet adott." << endl;
- }
- }
- while(hiba||hiba1);
- int psz[N];
- for (int i=0; i<N; ++i)
- {
- do
- {
- cout << i+1 << ". vizsgazo pontszama= ";
- cin >> sz;
- psz[i]=atoi(sz.c_str());
- hiba=(psz[i]==0)&&(sz!="0");
- if(hiba)
- {
- cout << "Nem jo jelsorozatot adott." << endl;
- }
- hiba1=(psz[i]<0)||(psz[i]>100);
- if(hiba1)
- {
- cout << "Nem 0 es 100 kozotti a pontszam." << endl;
- }
- }
- while(hiba||hiba1);
- }
- float atl=0;
- for (int i=0; i<N; ++i)
- {
- atl=atl+psz[i];
- }
- atl=atl/N;
- cout << "Atlag= " << atl << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment