الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

خطا عند عرض ما يحتويه الvector

مغلق
بدأه الحذر في 8 فبراير 2007 · 3 رد · 449 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم و رحمة الله و بركاته

انا سويت برنامج لحساب المعدل التراكمي لطلاب الثانوية

بس المشكلة انا لما ابغى اعرض ما يحتويه الفكتور و هي اسماء المواد يوقف البرنامج

ولما عملت debug طلع لي هذا الخطأ

---------------------------

Microsoft Visual C++

---------------------------

Unhandled exception in test.exe: 0xC0000005: Access Violation.

---------------------------

OK

---------------------------

و الخطا هذا يطلع عندما يوصل المؤشر حق ال debug الى مكان ما هو مكتوب في الكود "هنا المشكلة"

#include <iostream>
#include <string>
#include <vector>
#include <iomanip>

using namespace std;

int main()
{
	double degree[18];

	string names[18];	  

	names[0]="Quran";	   

	names[1]="To7id";	   

	names[2]="7HDITH";	   

	names[3]="Feqh";		  

	names[4]="Tafser";	   

	names[5]="Na7ow";	   

	names[6]="Adab";		 

	names[7]="English";	  

	names[8]="Math";		 

	names[9]="Phys";		 

	names[10]="Chems";	 

	names[11]="Biology  A7iya'a";	

	names[12]="Gelogy";  

	names[13]="Computer";	

	names[14]="Sprot";	 

	names[15]="Wataniha";   

	names[16]="Moadabh";	 

	names[17]="Selock";
	double hours[17];

/*	hours[0]=1.0;

	hours[1]=1.0;

	hours[2]=1.0;

	hours[3]=1.0;

	hours[4]=1.0;

	hours[5]=2.0;

	hours[6]=1.0;

	hours[7]=4.0;

	hours[8]=6.0;

	hours[9]=4.0;

	hours[10]=4.0;

	hours[11]=4.0;

	hours[12]=1.0;

	hours[13]=2.0;

	hours[14]=1.0;

	hours[15]=1.0;

	hours[16]=1.0;

	hours[17]=1.0;*/

	cout << "The full grade is each subjct is = ";

	double full_g;

	cin >> full_g;

//	cout <<"Grades \n";

	double sum_full=0.0;   double sum_part=0.0;

	double degree_full=0.0;   double degree_part=0.0;

	cout << "Put the degres infront each subject \n";

	bool more=true;

	while(more)
	{

		for(int i=0;i<18;i++)
		{
			cout << "Put the dgree for this subject "<<setw(4);
			cout << names<<"	 ";

			cin >> degree;

			cout << "Type noumber of HESSAS in a week	 ";

			cin >> hours;

			cout << "\n";

		}

		for(int q=0;q<18;q++)////////////////هنا المشكلة 
		{
			cout << names[q] << setw(5) << degree[q];
		}

		cout << "R u sure from these dgrees? (Y/N) ";

		string answer;

		cin >> answer;

		if(answer=="Y"||answer=="y")
		{
			more=false;
		}

		else more=true;

	}

	for(int j=0;j<18;j++)
	{
		sum_full=sum_full+(degree[j]*hours[j]);

		degree_full=degree_full+(50*hours[j]);

		sum_part=sum_part+degree[j];

		degree_part=degree_part+50;

	}

	double result_full=(sum_full/degree_full)*100.0;

	double result_part=(sum_part/degree_part)*100.0;

	cout << "\n" << "ur % in system 'TARAKOME' is =  "<< result_full << " % \n";

	cout << "ur % in normal system is = " << result_part<< " % \n";

	system("pause");

	return 0;
}

ارجو الافادة

و السلام عليكم و رحمة الله و بركاته

تم تعديل هذه المشاركة بواسطة الحذر في 8 فبراير 2007 في 02:26

I_can_always_make_you_smile_by_Praerion.jpg

#2

حسب رؤيتي السريعة للكود ، ما شفتك تنشيء اي vector !!

:::كوت بو 6:::

IDE : Microsoft Visual Studio 2005 Pro

#3

السلام عليكم ..

أعتقد أن المشكلة هي في عدد عناصر المصفوفة التي لديك ..

يعني عدد الساعات سيكون كالتي .. :

double hours[18];
#4

انا في بداية االبرنامج سويت VECTOR لاسماء المواد

يعني المستخدم ما راح يدخل اسماء المواد و لما ابغى اعرض اسماء المواد يجي الخطأ الي مكتوب فوق

لكن لما عملت for loop و نسخت vector الاسماء الى vector اخر صار الvector الجديد يعرض ما فيه

انا الي استنتجته ان لازم ادخل عناصر vector لازم يكون من قبل المستخدم ، ما ينفع اذا كتبنا عناصر الفكتور في

السورس كود.

هذا والله اعلم

I_can_always_make_you_smile_by_Praerion.jpg

هذا الموضوع مغلق.

مواضيع مشابهة