كود PHP:
#include<iostream.h>
#include<fstream.h>
#include<stdlib.h>
#include<iomanip.h>
#include<stdio.h>
struct string
{
char buffer[10] ;
};
void loadFile( string [] , int ) ;
void readPhrases ( string [] , int ) ;
void searchBuffer( string [] , int , char [] , int ) ;
void updateStats( char [] , int , int ) ;
void displayStats( void ) ;
main()
{
//char Phrases[10];
//int occurances ;
const int size = 100 ;
string buffer[size] ;
ifstream inClientFile( "stats.dat" , ios::trunc ) ;
loadFile( buffer , size ) ;
readPhrases( buffer , size ) ;
displayStats();
return 0;
}
void loadFile( string buffer[] , int size )
{
char filename[10] ;
cout << "Enter the name of the inpot file" << endl ;
cin >> filename ;
ifstream inClientFile( filename , ios::nocreate) ;
if( !inClientFile)
{
cout << "File could not be oppened" << endl ;
exit(1) ;
}
for( int i = 0 ; i < size ; i++ )
inClientFile >> buffer[i].buffer ;
cout << endl ;
}
void readPhrases( string buffer[] , int size )
{
char Phrases[10] ;
cout << "Enter a phrase ( Enter empty phrase to quite the program ) " << endl ;
while((cin >> Phrases) && (Phrases[0] != '\f'))
{
searchBuffer( buffer , size , Phrases , 10 ) ;
cout << "Enter a phrase ( Enter empty phrase to quite the program ) " << endl ;
}
}
void searchBuffer( string buffer[] , int size , char Phrases[] , int n )
{
bool found = true ;
int occurances = 0 ;
for(int i = 0 ; i < 100 ; i++ )
{
for (int j = 0 ; j < 10 ; j++ )
if( Phrases[j] != buffer[i].buffer[j] )
found = false ;
if ( found )
occurances ++ ;
}
cout << " ( " << occurances << " occurances found ) " << endl << endl ;
updateStats( Phrases , 10 , occurances ) ;
}
void updateStats( char Phrases [] , int size , int occurances )
{
ofstream outClientFile( "stats.dat" , ios::ate ) ;
outClientFile << Phrases << " " << occurances << endl ;
}
void displayStats()
{
char Ph[10] ;
int occ ;
ifstream inClientFile( "stats.dat" , ios::in ) ;
while( inClientFile >> Ph >> occ ) ;
cout << Ph << " " << occ << endl;
}
اضغط CONTROL + Z لانهاء ادخال المصطلحات
وأنا لم أجرب البرنامج:o
العملي دون النظري عمل أعمى والنظري دون العملي عمل ليس له فائدة
مرحبا مجددا ..
احم ..هالمرة ساطلب من بعد اذنك طبعا ...أن تساعدني بحل الواجب ,ليس تكاسلا مني وانما لظروف مرضية ألمت بي ,جعلتني ألازم البيت الأسبوع الماضي ولم أعلم بالواجب الا أمس , وعنا امتحانات ..
الواجب
given file "text.text"where each line contains the adress of each studant <write a complete program to print the shortest adress in this file
انتهى
وشكرا لك
السلام عليكم اذا ممكن ابغى برنامج يخفي نص داخل نص اخر
مثال لو كان عندي كلمة hello كلمه مكتوبه وأريد إخفاء حرف ال i ليكون هو الرساله المشفرة فانه يفترض ان اكون قد انشئت قاموس يحتوي على الكلمات المرادفه لهذه الكلمه مثال Hi فيقوم الكمبايلر بالبحث في المرادفات ليجد الكلمه المناسبه للاخفاء وهي hi إذ أن الحرف الثاني هو حرف ال i فيتم اخفاء الحرف وارسال كلمة hi
[PHP]
#include<iostream.h>
#include<fstream.h>
#include<stdlib.h>
struct string
{
char add[20] ;
};
main()
{
ifstream inAddressFile("text.text" , ios::nocreate ) ;
if(!inAddressFile)
{
cout << " file could not be opend " << endl ;
exit(1);
}
string address[100] ;
int acc[100] ;
char addr[20] ;
int i = 0 , counter = 0 ;
while( inAddressFile >> addr )
{
inAddressFile >> address[i].add ;
i++ ;
}
for( int j = 0 ; j < i ; j++ )
cout << address[j].add << endl ;
for( j = 0 ; j < i ; j++ )
{
counter = 0 ;
for( int k = 0 ; k < 20 ; k++ )
{
if( (int) address[j].add[k] == 0 )
break;
counter++ ;
}
acc[j] = counter ;
cout << counter << endl ;
}
int possition = 0 ;
int min = 0 ;
for( j = 0 ; j < i ; j++ )
if( acc[j] > min )
possition = j ;
cout << " The shortest address is " ;
cout << address[possition].add << endl ;
return 1 ;
}
[PHP/]
العملي دون النظري عمل أعمى والنظري دون العملي عمل ليس له فائدة
الله يخليك احتاجه رروري
البرنامج السابق لرابعة أما من ناحية برنامجك فيوجد واحد مشابه من صنعي قي معرض يرامج الأعضاء
العملي دون النظري عمل أعمى والنظري دون العملي عمل ليس له فائدة
السلام عليكم اخ علي انا شفت البرنامج هو مو نفس اللي ابغاه بس ممكن استفيد منه اذا ممكن بس تعطيني الكود حقه
السلام عليكم ورحمة الله وبركاته
ممكن أحد يساعدني بشرح هالبرنامج عن ايش يتكلم؟؟
ملا حظه انا ما درست لغة c انا ادرس c++ ومطالبه بهالبرنامج وانا ما فهمته!!!
التعديل الأخير تم بواسطة ضوء القـمـر ; 13-05-2007 الساعة 09:26 PM
البرنامج بالمرفق
جزيت خيرا
هذا هو الرنامج بعد ما صلحت الأخطاء فيه
تريدين شرح كيف يعمل أم شرح ماذا يعمل
كود PHP:
//The following program implements the Bellman-Ford algorithm in C.
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
/* Let INFINITY be an integer value not likely to be
confused with a real weight, even a negative one. */
#define INFINITY ((1 << 14)-1)
typedef struct
{
int source;
int dest;
int weight;
} Edge;
void BellmanFord(Edge edges[], int edgecount, int nodecount, int source)
{
int distance[10] ;
distance[0] = (int) malloc(nodecount * sizeof(distance));
int i, j;
for ( i = 0 ; i < nodecount ; ++i )
distance[i] = INFINITY ;
distance[source] = 0 ;
for (i=0; i < nodecount; ++i)
{
for ( j = 0 ; j < edgecount ; ++j)
{
if ( distance[edges[j].source] != INFINITY )
{
int new_distance = distance[edges[j].source] + edges[j].weight ;
if ( new_distance < distance[edges[j].dest] )
distance[edges[j].dest] = new_distance ;
}
}
}
for ( i = 0 ; i < edgecount; ++i )
{
if ( distance[edges[i].dest] > distance[edges[i].source] + edges[i].weight )
{
puts( "Negative edge weight cycles detected!" ) ;
//free( distance ) ;
//return ;
}
}
for ( i = 0 ; i < nodecount ; ++i )
{
printf("The shortest distance between nodes %d and %d is %d\n " , source , i , distance[i] ) ;
}
//free( distance ) ;
//return ;
}
int main(void)
{
/* This test case should produce the distances 2, 4, 7, -2, and 0. */
Edge edges[10] = {{0,1, 5}, {0,2, 8}, {0,3, -4}, {1,0, -2},
{2,1, -3}, {2,3, 9}, {3,1, 7}, {3,4, 2},
{4,0, 6}, {4,2, 7}};
BellmanFord(edges, 10, 5, 4);
return 0;
}
العملي دون النظري عمل أعمى والنظري دون العملي عمل ليس له فائدة
السلام عليكم
ياليت أخوي تحل لي هالسؤال واذا في إمكانية تشرحه لأني ضااااايع بالجزئية هذي مرررره
السلام عليكم
أرجو مساعدتي في كتابة البرنامج باستخدام array...
1- print a dimentional array that print even numbers
2-reverse the dimentional
3- print each raw in reverse order
و جزاكم الله خيرا...
هذا هو الحل للأخ the pluky
بقي عليك اضافة class وإذا وجد شيء لم تفهمه فأنا جاهز
#include<iostream.h>
#include<stdlib.h>
/*class Arrays
{
public :
float data[5] ;
};*/
void printarray ( float [] , int ) ;
void BubbleSort ( float [] , int ) ;
void SelectionSort ( float [] , int ) ;
void swap ( float * , float * ) ;
float array[5] = { 4 , 2 , 1 , -1 , -2 } ;
const int arraysize = 5 ;
int main()
{
while(1)
{
int choise ;
cout << " 1.read the array." << endl
<< " 2.Bubble sort. " << endl
<< " 3.Selection sort. " << endl
<< " 4.Exit. " << endl ;
cin >> choise ;
switch(choise)
{
case(1):
{
printarray( array , arraysize ) ;
break ;
}
case(2):
{
BubbleSort( array , arraysize ) ;
break ;
}
case(3):
{
SelectionSort( array , arraysize ) ;
break ;
}
case(4):
{
exit(1) ;
break ;
}
}
}
return 1 ;
}
void printarray ( float array[] , int arraysize )
{
for(int i = 0 ; i < arraysize ; i++)
cout << "array[" << i << "]= " << array[i] << endl ;
cout << endl ;
}
void BubbleSort ( float array[] , int arraysize )
{
bool swapped ;
do
{
swapped = false ;
for( int i = 0 ; i < arraysize - 1 ; i++ )
{
if( array[ i ] > array[ i + 1 ] )
{
swap( & array[ i ] , & array[ i + 1 ] ) ;
swapped = true ;
}
}
}
while ( swapped ) ;
}
void swap ( float * element1 , float * element2 )
{
float hold ;
hold = *element1 ;
*element1 = *element2 ;
*element2 = hold ;
}
void SelectionSort ( float array[] , int arraysize )
{
float max = array[ 0 ] ;
float max_pos = 0 ;
for ( float i = arraysize ; i > 0 ; i -- )
for ( int j = 0 ; j < i - 1 ; j++ )
{
if ( array[ j ] > max )
{
max = array[ j ] ;
max_pos = j ;
if ( i != max_pos )
swap ( &i , &max_pos ) ;
}
}
}
العملي دون النظري عمل أعمى والنظري دون العملي عمل ليس له فائدة
السلام عليكم و رحمة الله و بركاته ...
أذا يمكن أخي اريد كود للبحث في ملف عن الكلمات التي عدد أحرفها 3 أحرف و الناتج يخرج لنا عدد هذه الكلمات ....
أذا يمكن في أقرب فرصة و لك جزيل الشكر ...