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

[مخالف]تصحيح كود c++ .. pointer

مغلق
بدأه نسايم11 في 26 أبريل 2012 · 1 رد · 486 مشاهدة · في ارشيف قسم C/C++
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ,,

ارجوا مساعدتي في هذا الكود ,,

انا اجبت على فكرة البرنامج,,لكن طلبات السؤال في ترتيب البرنامج لم استطع حلها,,

استطيع وضع functhin ,, ولكن لدي مشكلة في pointer ,, فهمته بشكل عام..لكن يدخل في برنامج مثل هذا ..

للاسف مافهمت فكرته ..!!

ارجوا مساعدتي وجزاكم الله كل خير ..

Write a program that reads from the user two words (as array of characters) the program

then copies the shortest word into an array and prints the word to the user along with number of

characters in the word.

Your program should include:

Three character arrays and a pointer to each array

Function readArray which takes a pointer to an array of characters and asks the user to input

a word

Function findShortest which receives pointers to the two words, compares between them

and prints the shortest one along with the number of characters.

هذا الكود بدون الدخول في طلبات السؤال :

#include <iostream>
using namespace std;
void main()
{
char x[30]; char *x;
char y[30]; char *y;
char z[30]; char *z;
int countX=0,countY=0;
cout<<"enter first word"<<endl;
cin>>x;
cout<<"enter scound word"<<endl;
cin>>y;

for(int i=0;x!='\0';i++)
countX+=1;
for(int j=0;y[j]!='\0';j++)
countY+=1;

if(countX<countY)
cout<<"the shortest word is "<<x<<" with "<<countX<<" character";
else
cout<<"the shortest word is "<<y<<"with "<<countY<<"character";

}
#2

الأخ الكريم/الأخت الكريمة

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

مرحباً بكم في منتدى الفريق العربي للبرمجة

تأسف إدارة المنتدى لغلق الموضوع وذلك لمخالفته قوانين المشاركات .

قواعد طرح المشاركات

/index.php?showtopic=29343

شاكرين لكم حُسن تعاونكم

{username}

مدونتي: C++ Tips and Tricks

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

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