المساعد الشخصي الرقمي

عرض الإصدار الكامل : عمل flowchart لبرنامج C++



الميامن
02/05/2015, 07:18 PM
السلام عليكم

ممكن عمل حد يساعدني في عمل الفلوشارت لهذا البرنامج




#include (http://avb.s-oman.net/usertag.php?do=list&action=hash&hash=include) <iostream>
#include (http://avb.s-oman.net/usertag.php?do=list&action=hash&hash=include) <string>
#include (http://avb.s-oman.net/usertag.php?do=list&action=hash&hash=include) <cstdlib>
#include (http://avb.s-oman.net/usertag.php?do=list&action=hash&hash=include) <cerrno>
#include (http://avb.s-oman.net/usertag.php?do=list&action=hash&hash=include) <climits>
#include (http://avb.s-oman.net/usertag.php?do=list&action=hash&hash=include) <stdexcept>
#include (http://avb.s-oman.net/usertag.php?do=list&action=hash&hash=include) <stdlib.h>

using namespace std;

// Function to Convert String to integer
int toInteger(const std::string &s) {
char *end;
errno = 0;

// Convert
long result = strtol(s.c_str(), &end, 10);

// Check if the conversion succeeded. if not, throw an error.
if (errno == ERANGE || result > INT_MAX || result < INT_MIN || s.length() == 0 || *end != '\0')
throw invalid_argument("toInteger Function: invalid string");

return result;
}

// Function to check if a number is within bounds.
void checkBounds(const int &num, const int &lower_bound, const int &upper_bound) {
if (num < lower_bound || num > upper_bound)
throw out_of_range("checkBounds: Number is out of bound");
}

// Main Program Run.
int main(int argc, char* argv[]) {

int count[10] = {0}; // Marks Array
int i; // For looping
string markStr; // Storing User Input
int mark = 0; // User Input in Integer Format

while (mark >= 0) {
try {

// Read User Input
cout << "Please input a mark: ";
cin >> markStr;

// Convert the mark from String to integer
mark = toInteger(markStr);

// Check Bounds then Add To Category
if (mark >= 0) {
/* Check if the mark is within our range
** in C++, you must check if the index exist before you change a value.
** Example: count[20] is not correct and the program will be stuck if you access it. */

checkBounds(mark, 0, 99);

// Increment the counter
count[mark / 10]++;
}

} catch (invalid_argument ex) {
// Catch if user types letters instead of numbers.
cout << "Please Input Numbers from 0 to 100 Only." << endl;
} catch (out_of_range ofrEx) {
// Catch if numbers are 100 and above..
if (mark > 100)
cout << "Please Input Numbers from 0 to 100 Only." << endl;
else
count[9]++;
}
}

// Show Categories
for (i = 0; i < 10; i++) {
cout << "Category[" << i << "]: " << count[i] << endl;
}

// pause the program.
system("pause");

return 0;
}

Xade
05/05/2015, 09:35 AM
هذا flowchart مفصل

http://s10.s-oman.net/i/00028/attl8mkr8q55_t.jpg (http://share.s-oman.net/attl8mkr8q55.htm)