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

إيجاد خطأ في كود المصفوفات

بدأه mohammednoor في 3 مايو 2012 · 8 رد · 447 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم إخواني أنا كتبت كود المصفوفة 5BY 5 يوجد أغلاط ولا أعرف ما هي يمكن نسيان فاصلة أو خطأ مطبعي أرجو من الأساتذة حل الموضوع مع كامل الشكر والتقدير

//---------------------------------------------------------------------------

#include <vcl.h>
#include <iostream>
#pragma hdrstop

//---------------------------------------------------------------------------

#pragma argsused
int main(int argc, char* argv[])
{
int counter=0;
{
char array[5][5];
for(int i=0; i<5; i++)
{
for(int j=0; j<5; j++)
cin>>array[j];
}
for(int i=0; i<5; i++)
{
for(int j=0; j<5; j++)
{
if(int j==4)
{
if(array[j]=='a'||array[j]=='e'||array[j]=='o')
counter++
}
}
}
for(int i=0; i<5; i++)
{
for(intj=0; j<5; j++)
{
if(array[j] !=' ')
array[j]++;
}
}
        return 0;
}
//---------------------------------------------------------------------------
#2

أخى الكريم:

أخى ما فدة كتلة الكود الثانية والثالثة

واعتقد ان كتلة الكود الثالة يمكن ان تحذف

حاول ان تكتب لنا وظيفة البرنامج فى صورة 3 خطوات واضحة(خوارزمية)

اخى الكود بعد التعديل:

/* 
 * File:   main.cpp
 * Author: Mohammed Abu Zayed
 * * Created on May 3, 2012, 7:12 AM
 */

#include <iostream>
using namespace std;

int main()
{
    int counter = 0;
    char array[5][5];

    //كتلة الكود الاولى
    for (int i = 0; i < 5; i++)
    {
        for (int j = 0; j < 5; j++)
            cin >> array[j];
    }

    // كتله الكود الثانية
    for (int i = 0; i < 5; i++)
    {
        int j=0; //فليكن خارج foe حتى تراة if
        for ( j = 0; j < 5; j++)
        {
            if ( j == 4)
            {
                if (array[j] == 'a' || array[j] == 'e' || array[j] == 'o')
                    counter++;
            }
        }
    }

    //كتلة الكود الثالثة
    for (int i = 0; i < 5; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            if (array[j] != ' ')
                array[j]++;
        }
    }
    return 0;

}
//---------

هذا والله ولى التوفيق

تم تعديل هذه المشاركة بواسطة AudaNix في 3 مايو 2012 في 10:06

post-15367-027053900%201340345097.gifpost-15367-087183200%201340344597.gif
post-247365-0-10080400-1379403554_thumb.

#3

السلام عليكم أخوي هذا المطلوب عندي من كل فقرة في الكود في الحل لايعطي إخراج عند تجربة البرنامج هذا هو السؤال المطلوب لكتابة الكود

اقتباس

Write a C++ program Consider a 5-by-5 array of characters. to accomplish each of the following operations:

a. Declare the above array.

b. Read the array.

c. Find and print the number of vowels (a,e,o) in the off diagonal of the array.

d. Replace each non-space character in the array by its next character value in the alphabetic order (Example: letter b will be replaced by c, letter M will be replaced by N, and so on).

#4

السلام عليكم

حسب ما فهمت يجب العثور على عدد حروف العلة خارج قطر المصفوفة وإستبدال الحرف بالذي يليه بالترتيب الأبجدي

إليك هذا الحل ربما يفيدك

#include<iostream>
using namespace std;

int main() {
	char character = 0;
	int counter = 0;
	char array[5][5];
	int diagonlIndex = 0;

	for(int i = 0; i < 5; i++) {

    	for(int itr = 0; itr < 5; itr++) {

        	cin >> character;

        	if(itr != diagonlIndex) {
            	if(character == 'e' || character == 'a' || character == 'o') {
                	counter++;
            	}
        	}

        	if(character != ' ') {
            	array[itr] = character + 1;
        	}
    	}

    	cout << endl;

    	diagonlIndex++;
	}
	cout << "The number of vowels off diagonal is : " << counter << endl;
	return(0);
}

و الله ولي التوفيق

#5

طيب أخوي شو هو الإخراج لهل برنامج

#6

ماذا تقصد ب الإخراج

#7

Output

البرنامج لما تشغلو وتكتب فيه لازم يكون هنالك إخراج يعني الناتج أنا ماعرفت أطلع الناتج يعني وشو فائدة البرنامج يلي كتبتو بدون ناتج ملموس

#8

هذا البرنامج كامل وكل خطوة به فى صورة تعليق فوق الكود

ما اريد ان اثير اهتمامك بة هو السطر:

++character

عند زيادة هذا الحرف فأن قيمتة تتحول من a الى b .

والدالة isspace دالة بسيطة راجعها من هنا

//Write a C++ program Consider a 5-by-5 array of characters. 

//to accomplish each of the following operations:
//
//a. Declare the above array.
//b. Read the array.
//c. Find and print the number of vowels (a,e,o) in the off diagonal of the array.
//d. Replace each non-space character in the array by its next character value in 
//   the alphabetic order (Example: letter b will be replaced by c, 
//   letter M will be replaced by N, and so on).
#include<iostream>
#include <ctype.h>


using namespace std;

int main()
{
    char character = 0;
    int counter = 0;
    //a. Declare the above array.
    char Array5by5[5][5];
    int diagonlIndex = 0;
    //b. Read the array.
    for (int i = 0; i < 5; i++)
        for (int itr = 0; itr < 5; itr++)
        {
            cout << i + 1 << ":" << itr + 1 << " : ";
            cin >> Array5by5[itr];
        }
    //c. Find and print the number of vowels (a,e,o) in the off diagonal of the array.
    for (int i = 0; i < 5; i++)
    {
        for (int itr = 0; itr < 5; itr++)
        {
            character = Array5by5[itr];
            if (character == 'e' || character == 'a' || character == 'o')
                counter++;
            //d. Replace each non-space character in the array by its next character value
            if (!isspace(character))
                Array5by5[itr] = ++character;
        }

        cout << endl;        
    }
    cout << "The number of vowels off diagonal is : " << counter << endl;

    for (int i = 0; i < 5; i++)
        for (int itr = 0; itr < 5; itr++)
        {
            cout << i + 1 << ":" << itr + 1 << " : ";
            cout << Array5by5[itr] << endl;
        }
    cin.get(); // getch();
    return (0);
}

المدخلات والمخرجات:

1:1 : A
1:2 : a
1:3 : B 
1:4 : b
1:5 : a
2:1 : g
2:2 : h
2:3 : r
2:4 : d
2:5 : j
3:1 : k
3:2 : lo
3:3 : 3:4 : e
3:5 : r
4:1 : c
4:2 : d
4:3 : s
4:4 :  
d
4:5 : d
5:1 : x
5:2 : d
5:3 : e
5:4 : r
5:5 : d


The number of vowels off diagonal is : 5
1:1 : B
1:2 : b
1:3 : C
1:4 : c
1:5 : b
2:1 : h
2:2 : i
2:3 : s
2:4 : e
2:5 : k
3:1 : l
3:2 : m
3:3 : p
3:4 : f
3:5 : s
4:1 : d
4:2 : e
4:3 : t
4:4 : e
4:5 : e
5:1 : y
5:2 : e
5:3 : f
5:4 : s
5:5 : e

RUN SUCCESSFUL (total time: 40s)

اللهم ارزق كاتب وقارىء المشاركة ومن ساهم بنشرها مغفرتك بلا عذاب ..

1

post-15367-027053900%201340345097.gifpost-15367-087183200%201340344597.gif
post-247365-0-10080400-1379403554_thumb.

#9

شكرا أخواني على المساعدة والله يجعلها في ميزان حسناتكن

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