Advertisement
RicoHeartless

Laba 1.3 (Unfinished ?)

Sep 28th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.48 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2.  
  3. #include <cstdlib>
  4. #include <stdio.h>
  5. #include <iostream>
  6. #include <cstring>
  7. #include <cmath>
  8. #include <iomanip>
  9.  
  10. using namespace std;
  11.  
  12. void base(char name[], char num[], char mark[], const int k) {
  13.     int z = 0, inum = 0, h = 0;
  14.     char qName[255]{};
  15.     cout << "Enter num of students: " << endl;
  16.     cin >> inum;
  17.     cin.ignore();
  18.     for (int m = 1; m <= inum; m++) {
  19.         cout << "student " << m << ":" << endl;
  20.         cout << "Enter name: " << endl;
  21.         if (inum == 1){ cin.get(name,255); }
  22.  
  23.         cin.getline(name, k);
  24.         cout << "Enter zalik: " << endl;
  25.         cin.getline(num, k);
  26.         cout << "Enter mark: " << endl;
  27.         cin.getline(mark, k);
  28.         for (int i = 0; i<strlen(mark); i++) {
  29.             if (isdigit(mark[i]) && (int(mark[i]) <= 51) && (48 <= int(mark[i]))) {
  30.                 if (int (mark[i]) < 48){
  31.                     cout << "Wrong marks!" << endl;
  32.                     exit (0);
  33.                 }
  34.                 z++;
  35.                 for (int i(0); i <= strlen(name); i++){
  36.                             qName[i+h] = name[i];
  37.                         if (i+h == strlen(name) - 1){
  38.                             h = h + i + 1;
  39.                             qName[h] = 35;
  40.                             h = i + 2;
  41.                             break;
  42.                         }
  43.                 }
  44.                 break;
  45.             }
  46.         }
  47.     }
  48.     cout << "Students with bad marks: " << endl;
  49.     for (int i(0); i <= strlen(qName) - 1; i++){
  50.         if (qName[i] == 35){ qName[i] = 32; cout << endl << "--------------" << endl; }
  51.         else
  52.         {
  53.             cout << qName[i];
  54.         }  
  55.     }
  56.     cout << '\n';
  57. }
  58. int main() {
  59.     const int k = 255; // length of array
  60.     char name[k];// array
  61.     char num[k];
  62.     char mark[k];
  63.     base(name, num, mark, k);
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement