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

What Is Wrong With This?

بدأه 7asibat في 23 يونيو 2009 · 2 رد · 531 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <ctype.h>

int stringLength(char inputString[])

{

int length = 0;

for (int i = 0; inputString!= '\0'; i++)

length++;

return length;

}

void main (void)

{

int count=0; int n=0; int i,j;

FILE *p=fopen("xx.txt","r");

if(p==NULL)

{

printf("wrong");

exit(1);

}

//-----------read from file to string array equation----------------------

char equations[50][150];

char *fileline=(char *)malloc(100*sizeof(char));

int equations_count=0;

while(fscanf(p,"%s",fileline)!=EOF)

{

int len;

len= stringLength(fileline);

for(j=0;j<=len;j++)

equations[equations_count][j]=fileline[j];

equations_count++;

puts(fileline);

}

printf("\n THE NO OF EQN =%d\n",equations_count);

fclose(p);

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

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

int b=equations_count;

float **coeff=(float**)malloc(b*sizeof(float*));

for(i=0;i<b;i++)

coeff=(float*)malloc(b*sizeof(float));

for(i=0;i<b;i++)

for(j=0;j<b;j++)

{

coeff[j]=0;

if(j%b==0)

printf("\n");

printf("%f \t",coeff[j]);

}

//-------------coeff initialization matrix--------------------------

float *result=(float*)malloc(b*sizeof(float));

for(i=0;i<b;i++)

result=0;

//-------------result matrix----------------------------------------

char **v=(char**)malloc(b*sizeof(char*));

for(i=0;i<b;i++)

v=(char*)malloc(100*sizeof(char));

//-------------var_names(array of string)---------------------------

char stock[100];int k=0;int t=0;

for(i=0;i<b;i++)

for(j=0;j<(strlen(equations)+1);j++)

{

if(isalpha(equations[j])!=0)

{

stock[k]=equations[j];

k++;

}

else

if(strlen(stock)!=0)

{

stock[k]=NULL;

char *p;

for(i=0;i<b;i++)

{

p=strstr(&v[0],stock);

if(p!=NULL)

{

t++;

}

}

if(t==0)

{

strcpy(v[t],stock);

t++;

}

k=0;

stock[0]='\0';

}

}

printf("%s",v[0]); المشكله انو لما بيجي يطبع بيطبع رابيش

قبل مانحط فيه النال stock مش المفرض يطبع اول حاجه كانت في

}

#2

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

جرب الكود الاتى


#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int stringLength(char inputString[])
{
int length = 0;

for (int i = 0; inputString!= '\0'; i++)

length++;

return length;
}
void main (void)
{

int count=0; int n=0; int i,j;
FILE *p=fopen("xx.txt","r");
if(p==NULL)
{
printf("wrong");
exit(1);
}
//-----------read from file to string array equation----------------------
char equations[50][150];
char *fileline=(char *)malloc(100*sizeof(char));

int equations_count=0;
while(fscanf(p,"%s",fileline)!=EOF)
{
int len;
len= stringLength(fileline);
for(j=0;j<=len;j++)
equations[equations_count][j]=fileline[j];
equations_count++;
puts(fileline);
}
printf("\n THE NO OF EQN =%d\n",equations_count);

fclose(p);
//----------------------------------------------------------------
//----------------------------------------------------------------
int b=equations_count;
float **coeff=(float**)malloc(b*sizeof(float*));
for(i=0;i<b;i++)
coeff=(float*)malloc(b*sizeof(float));
for(i=0;i<b;i++)
for(j=0;j<b;j++)
{
coeff[j]=0;
if(j%b==0)
printf("\n");
printf("%f \t",coeff[j]);
}
//-------------coeff initialization matrix--------------------------
float *result=(float*)malloc(b*sizeof(float));
for(i=0;i<b;i++)

result=0;
//-------------result matrix----------------------------------------
char **v=(char**)malloc(b*sizeof(char*));
for(i=0;i<b;i++)
v=(char*)malloc(100*sizeof(char));



//-------------var_names(array of string)---------------------------
char stock[100];int k=0;int t=0;

for(i=0;i<b;i++)
for(j=0;j<strlen(equations);j++)
{
if(isalpha(equations[j]))
{
stock[k]=equations[j];
k++;
}
else
if(k>0)
{
stock[k]='\0';
char *p;
for(i=0;i<b;i++)
{
p=strstr(&v[0],stock);
if(p!=NULL)
{
t++;
}
}
if(t>=0)
{
strcpy(v[t],stock);
t++;

}
k=0;
stock[0]='\0';
}
}
printf("\n");
printf("%s\n",v[0]);
}
#include <stdio.h>

بس يا أخى

هل تقصد بالمصفوفه الثنائيه v

مصفوفة المتغيرات

اريد توضيح منك للمطلوب من البرنامج بالضبط

أعرف انك تريد فصل المعاملات فى مصفوفه

وكذلك المتغيرات

صح ولا لأ؟

يا ريت توضح ما تريد أكثر

سلام

اللهم صل على سيدنا محمد وعلى آله وصحبه وسلم

#3

بســم الله الـرحمــن الرحيــم

الف شكر لحضرتك علي الرد بس الحمد لله انا حلصت من المشكله

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