Advertisement
RicoHeartless

Laba 1.3 (2K) [BETA]

Sep 25th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.74 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2.  
  3. #include <iostream>
  4. #include <cctype>
  5. #include <Windows.h>
  6.  
  7. using namespace std;
  8.  
  9. char* decoder(char* arr, int lenghtName){
  10.     int count = 0;
  11.     int pos = 0;
  12.     char* LOOSERNAME = new char[lenghtName]{};
  13.     for (int i(0); i <= strlen(arr); i++){
  14.         if (arr[i] == ';'){
  15.             arr[i] = ' '; count++;
  16.             if (count == 2)pos = i;
  17.         }
  18.     }
  19.         if (count == 2){
  20.             for (int i(pos); i != '\0'; i++){
  21.                 if (arr[i] == '1' || arr[i] == '2'){
  22.                     for (int k(0); k <= lenghtName - 2; k++){ //48-57
  23.                         LOOSERNAME[k] = arr[k];
  24.                     }
  25.                     return LOOSERNAME;
  26.                     break;
  27.                 }
  28.             }
  29.         }
  30.     delete[] LOOSERNAME;
  31. }
  32.  
  33. void sum(char *Name, char *Code, char *Marks, int NumStudents){
  34.     char **studentarr = new char*[NumStudents];
  35.     int lengthName = strlen(Name);
  36.     for (int count = 0; count < NumStudents; count++)
  37.         studentarr[count] = new char[3];
  38.             studentarr[NumStudents] = strcat(Name, Code);
  39.             strcat(studentarr[NumStudents], Marks);
  40.             char* looser = decoder(studentarr[NumStudents], lengthName);
  41.             cout << looser << endl;
  42.     for (int count = 0; count < 2; count++)
  43.         delete[]studentarr[count];
  44.     cin.get();
  45. }
  46.  
  47.  
  48. void main(){
  49.     int students = 0;
  50.     char name[20];
  51.     char code[10];
  52.     char marks[10];
  53.     cout << "Enter n of students: " << endl;
  54.     cin >> students;
  55.     for (int stcount(0); stcount < students; stcount++){
  56.         cin.clear();
  57.         cin.get();
  58.         cout << "Name: (end it with ';')" << endl;
  59.         cin.getline(name, 20);
  60.         cin.clear();
  61.         cout << "Code of transcripsion: (end it with ';')"<< endl;
  62.         cin.getline(code, 20);
  63.         cin.clear();
  64.         cout << "Marks from 5 subjects (3-4-5-6-7): (end it with ';')" << endl;
  65.         cin.getline(marks, 10);
  66.         cin.clear();
  67.         sum(name, code, marks, students);
  68.         memset(name, 0, _countof(name));
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement