Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <cstdlib>
- #include <stdio.h>
- #include <iostream>
- #include <cstring>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- void base(char name[], char num[], char mark[], const int k) {
- int z = 0, inum = 0, h = 0;
- char qName[255]{};
- cout << "Enter num of students: " << endl;
- cin >> inum;
- cin.ignore();
- for (int m = 1; m <= inum; m++) {
- cout << "student " << m << ":" << endl;
- cout << "Enter name: " << endl;
- if (inum == 1){ cin.get(name,255); }
- cin.getline(name, k);
- cout << "Enter zalik: " << endl;
- cin.getline(num, k);
- cout << "Enter mark: " << endl;
- cin.getline(mark, k);
- for (int i = 0; i<strlen(mark); i++) {
- if (isdigit(mark[i]) && (int(mark[i]) <= 51) && (48 <= int(mark[i]))) {
- if (int (mark[i]) < 48){
- cout << "Wrong marks!" << endl;
- exit (0);
- }
- z++;
- for (int i(0); i <= strlen(name); i++){
- qName[i+h] = name[i];
- if (i+h == strlen(name) - 1){
- h = h + i + 1;
- qName[h] = 35;
- h = i + 2;
- break;
- }
- }
- break;
- }
- }
- }
- cout << "Students with bad marks: " << endl;
- for (int i(0); i <= strlen(qName) - 1; i++){
- if (qName[i] == 35){ qName[i] = 32; cout << endl << "--------------" << endl; }
- else
- {
- cout << qName[i];
- }
- }
- cout << '\n';
- }
- int main() {
- const int k = 255; // length of array
- char name[k];// array
- char num[k];
- char mark[k];
- base(name, num, mark, k);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement