120 条题解
-
-1施支林 LV 8 @ 2017-07-31 19:52:35
Var
s:string;
k,i,j,yb,sum,l,sum1,sz,cs:longint;
num:real;
zf:char;
Begin
readln(s);
for i:=1 to length(s) do
if s[i] in ['a'..'z'] then
begin
zf:=s[i];
break;
end;
i:=pos(zf,s);
write(zf,'=');
while i>0 do
begin
k:=pos('=',s);
yb:=0;
j:=i-1; l:=1; cs:=1; sz:=0;
while s[j] in ['0'..'9'] do
beginsz:=sz+(ord(s[j])-48)*cs;
dec(j);
inc(l);
cs:=cs*10;
end;
if j=i-1 then
sz:=1;
if (s[j]='-') or (s[j]='+') then
begin
inc(l);
if s[j]='-' then
sz:=0-sz;
end;
if i<k then
sum:=sum+sz
else
sum:=sum+(0-sz);
if i=1 then
delete(s,1,1)
else
delete(s,i-l+1,l);
i:=pos(zf,s);
end;
while length(s)>1 do
begin
k:=pos('=',s); sz:=0;
for i:=1 to length(s) do
begin
if ((s[i]='-') or (s[i]='+') or (s[i]='=')) and (sz>0) then
break;
if (s[i]='-') or (s[i]='+') then
zf:=s[i]
else
if s[i] in ['0'..'9'] then
sz:=sz*10+ord(s[i])-48;
end;
if zf='-' then
sz:=0-sz;
i:=i-1;
if i<k then
sum1:=sum1-sz
else
sum1:=sum1+sz;
delete(s,1,i);
end;
if (sum=0) or (sum1=0) then
num:=0
else
num:=sum1/sum;
writeln(num:0:3);
readln;
end.
这道题,,不知道有没有人跟我的做法一样,我是先移项,将它变成一边是未知数,一边是有理数。。 -
-12017-05-10 13:08:24@
何必把代码写的那么长。。。
18行即可,不超过80列#include <bits/stdc++.h> using namespace std; int main() { int xc=0,cc=0,con=1,flag=1,flag2=1;char x,c;bool isnew=1; while(c=getchar(),c!=EOF) { if(isalpha(c))x=c,xc+=con*flag*flag2,con=flag2=isnew=1; else if(c=='=')cc+=con*flag*flag2*(isnew^1),con=flag2=isnew=1,flag=-1; else if(c=='-')cc+=con*flag*flag2*(isnew^1),con=isnew=1,flag2=-1; else if(c=='+')cc+=con*flag*flag2*(isnew^1),con=flag2=isnew=1; else if(isdigit(c)){if(isnew)con=isnew=0;con=con*10+c-'0';} } float ans=float((float)(-(cc+con*flag*flag2*(isnew^1)))/(float)(xc)); if(abs(ans)<1e-6)ans=0; printf("%c=%.3f\n",x,ans); return 0; }
-
-12017-01-29 20:20:21@
坑爹模拟
c++
#include<iostream>
#include<string>
using namespace std;
int main()
{
string sA, sUn;
int nA, nB, nRat, i, j, nLen, nEqu, nT;
double nAns;
while (getline(cin, sA))
{
nA = 0;
nB = 0;
nLen = sA.size();
i = 0;
nEqu = sA.find('=');
while(i<nLen)
{
nT = 1;
if (i > nEqu)
nT = -1;
j = i;
nRat = 0;
if (i != 0)
{
if (sA[i - 1] == '-')
nT *= -1;
}
if (sA[i] >= 'a'&&sA[i] <= 'z')
{
if (i == 0)
nRat = 1;
else
{
if (!(sA[i - 1] >= '0'&&sA[i - 1] <= '9'))
nRat = 1;
}
}
while (sA[j] >= '0'&&sA[j] <= '9')
{
nRat = nRat * 10 + sA[j] - '0';
j++;
if (j == nLen)
break;
}
if (sA[j] >= 'a'&&sA[j] <= 'z')
{
nA += nRat*nT;
sUn = sA[j];
}
else
nB += nRat*nT;
i = j;
i++;
}
nAns = -1.0*nB / nA;
cout << sUn;
printf("=%.3f\n", nAns);
}
return 0;
}
-
-12016-11-10 21:14:29@
题目难度不大,注意一下b接近于0的时候直接输出0.000,防止正负号的出现
cpp
#include <stdio.h>
#include <string.h>
#include <math.h>
char func[10000];
int n,i,j;
int alpha(char c)
{
if('0'<=c&&c<='9') return c-'0';
if(c=='+') return -1;
if(c=='-') return -2;
if(c=='=') return -3;
if('a'<=c&&c<='z') return 100;
return -4;//空格和其它制表符?
}
int main()
{
memset(func,0,sizeof(func));
scanf("%s",func);
n=strlen(func);
func[n]='+';n++;//防止不能有效的加上最后一个数
char x=0;
for(i=0;;i++)
if(alpha(func[i])==100)
{
x=func[i];
break;
}
int a=0,b=0;//标准形式ax=b
int pos=1,temp=0;
if(alpha(func[0])==-2) pos=-1;
for(i=0;;i++)
{
if(alpha(func[i])==-4) continue;
if(func[i]=='-') {
b-=temp*pos;
temp=0;
pos=-1;
continue;
}
if(func[i]=='+') {
b-=temp*pos;
temp=0;
pos=1;
continue;
}
if(func[i]=='=') {
b-=temp*pos;
temp=0;
pos=1;
i++;
break;
}
if(func[i]==x) {
if(temp==0) a+=pos;//x的前面如果没有数则默认系数为1
else a+=temp*pos;
temp=0;
continue;
}
temp*=10;
temp+=alpha(func[i]);
}
for(;i<n;i++)
{
if(alpha(func[i])==-4) continue;
if(func[i]=='-') {
b+=temp*pos;
temp=0;
pos=-1;
continue;
}
if(func[i]=='+') {
b+=temp*pos;
temp=0;
pos=1;
continue;
}
if(func[i]==x) {
if(temp==0) a-=pos;
else a-=temp*pos;
temp=0;
continue;
}
temp*=10;
temp+=alpha(func[i]);
}
if(fabs(b)<0.001) {
printf("%c=0.000",x);//特判0输出
return 0;
}
printf("%c=%.3f",x,(double)b/(double)a);
return 0;
}
强行不使用atoi函数(#滑稽) -
-12015-06-05 16:48:39@
以前我觉得这题目难得下不了手...也许当时脑残吧。现在这个程序写的也不怎么好,一个段落重复使用。
其实就是数字字符串转数字,判断是一个项还是系数,进行移项就可以了。#include<stdio.h>
#include<string.h>
int main( )
{
char s[10001],zm=0,flag=0;
int i,len,j,z,lc=1,x=0;
int zhan[1001];
int top=0;
float left=0,right=0;gets(s);
len=strlen(s)-1;
if(s[0]>=48 && s[0]<=57)
{
j=-1;
while(s[j+1]>=48 && s[j+1]<=57)
{
j++;
top++;
zhan[top]=s[j]-48;
}for(z=top;z>=1;z--)
{
x=x+lc*zhan[z];
lc=lc*10;
}if(s[j+1]>=97 && s[j+1]<=122)
{
if(flag==0) left=left+x;
else left=left-x;
}else
{
if(flag==0) right=right-x;
else right=right+x;
}x=0;
lc=1;
top=0;
}for(i=0;i<=len;i++)
{
if(s[i]=='=')
{
flag=1;j=i;
while(s[j+1]>=48 && s[j+1]<=57)
{
j++;
top++;
zhan[top]=s[j]-48;
}for(z=top;z>=1;z--)
{
x=x+lc*zhan[z];
lc=lc*10;
}if(s[j+1]>=97 && s[j+1]<=122)
{
if(flag==0) left=left+x;
else left=left-x;
}else
{
if(flag==0) right=right-x;
else right=right+x;
}i=j;
x=0;
lc=1;
top=0;
}if(s[i]=='+')
{
j=i;
while(s[j+1]>=48 && s[j+1]<=57)
{
j++;
top++;
zhan[top]=s[j]-48;
}for(z=top;z>=1;z--)
{
x=x+lc*zhan[z];
lc=lc*10;
}if(s[j+1]>=97 && s[j+1]<=122)
{
if(flag==0) left=left+x;
else left=left-x;
}else
{
if(flag==0) right=right-x;
else right=right+x;
}i=j;
x=0;
lc=1;
top=0;
}if(s[i]=='-')
{
j=i;
while(s[j+1]>=48 && s[j+1]<=57)
{
j++;
top++;
zhan[top]=s[j]-48;
}for(z=top;z>=1;z--)
{
x=x+lc*zhan[z];
lc=lc*10;
}if(s[j+1]>=97 && s[j+1]<=122)
{
if(flag==0) left=left-x;
else left=left+x;
}else
{
if(flag==0) right=right+x;
else right=right-x;
}i=j;
x=0;
lc=1;
top=0;
}if(s[i]>=97 && s[i]<=122) zm=s[i];
}printf("%c=%.3f",zm,right/left);
return 0;
}
-
-12014-12-30 18:25:57@
#include <stdio.h>
#include <stdlib.h>
char x;
int test(char *s){//0 为无字母
int i;
for(i=0;s[i];i++)
if(s[i]>='a' && s[i]<='z'){
x=s[i];
if(i==0 || i==1
&& (s[0]=='+'||s[0]=='-'||s[0]=='='))
s[i]='1',i++;
s[i]=0;
return 1;
}
return 0;
}int main(void){
double value[2]={0,0};char line[2000],digit[20],*p;
int i,c=0,ret;
gets(line);
for(p=line,i=0;;p++){
if(*p=='+' || *p=='-' || *p=='=' || p=='\0'){
digit[i]='\0';
ret=test(digit);
value[ret]+=(double)(atoi(digit) ((c==0 && ret==0|| c==1 && ret==1)?1:-1));
//printf("%lf %d %d\n",(double)(atoi(digit)),c,ret);
i=0;
}
if(*p=='\0')
break;
if(*p=='='){
c=1;
p++;
}
digit[i]=*p;
i++;
}
printf("%c=%.3lf\n",x,value[0]/value[1]);
return 0;
} -
-12014-11-07 16:55:40@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cmath>using namespace std;
int main()
{
char arr[256];
long long pone = 0, num = 0;
char uk = 0;
long long xs = 1;
bool first = true;
int i = 0;
int zf = 0;
int lr = 0;cin >> arr;
lr = 1;
if (arr[0] == '-')
{
zf = -1;
i++;
}
else
{
zf = 1;
}
for (; i < (int)strlen(arr); i++)
{
if (arr[i] == '=')
{
num += xs * zf * lr;
lr = -1;
if (arr[i + 1] == '-')
{
zf = -1;
i++;
}
else
{
zf = 1;
}
xs = 1;
first = true;
continue;
}
if (arr[i] == '+')
{
num += xs * zf * lr;
zf = 1;
xs = 1;
first = true;
continue;
}
if (arr[i] == '-')
{
num += xs * zf * lr;
zf = -1;
xs = 1;
first = true;
continue;
}
if ((arr[i] < '0') || (arr[i] > '9'))
{
pone += xs * zf * lr;
uk = arr[i];
if (arr[i + 1] == '+')
{
zf = 1;
}
else
if (arr[i + 1] == '-')
{
zf = -1;
}
else
if (arr[i + 1] == '=')
{
lr = -1;
if (arr[i + 2] == '-')
{
zf = -1;
i++;
}
else
{
zf = 1;
}
}
i++;
xs = 1;
first = true;
continue;
}
if (first)
{
xs = 0;
first = !first;
}
xs = xs * 10 + arr[i] - '0';
}
if (!first)
{
num += xs * zf * lr;
}
cout << setiosflags(ios::fixed);
if (((double) - num) / pone == 0.0)
{
cout << uk << "=0.000" << endl;
}
else
{
cout << uk << "=" << setprecision(3) << ((double) - num) / pone << endl;
}
return 0;
}30AC
-
-12014-11-04 19:49:26@
135AC庆祝
-
-12014-11-04 19:49:13@
一年前的难题,如今的水题
-
-12014-11-04 19:48:43@
var s:string;f,i,c,k,x,y:longint;z:double;g:char;
begin
readln(S);f:=length(s);i:=1;s:=s+'@';
while s[i]<>'=' do
begin
if s[i]='-' then begin inc(i);k:=-1;end
else
begin
if s[i]='+' then inc(i);
k:=1;
end;
dec(i);c:=0;
while s[i+1]in['0'..'9']do begin inc(i);c:=c*10+ord(s[i])-48;end;
c:=c*k;
if s[i+1]in['a'..'z']then begin g:=s[i+1];inc(i);x:=x+c;end
else y:=y-c;
inc(i);
end;
inc(i);
while s[i]<>'@' do
begin
if s[i]='-' then begin inc(i);k:=-1;end
else
begin
if s[i]='+' then inc(i);
k:=1;
end;
dec(i);c:=0;
while s[i+1]in['0'..'9']do begin inc(i);c:=c*10+ord(s[i])-48;end;
c:=c*k;
if s[i+1]in['a'..'z']then begin g:=s[i+1];inc(i);x:=x-c;end
else y:=y+c;
inc(i);
end;
z:=y/x;writeln(g,'=',z:0:3);
end.
-
-12014-08-21 19:46:20@
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<sstream>
#include<stack>
#include<set>
#include<string>
#include<valarray>
#include<vector>
using namespace std;typedef long long ll;
char ch[1005],chunkown;
int step,num,nowflag;
double ans,ds,sz;int main()
{
cin>>ch;
if (ch[0]=='-')
{
step=1;
num=0;
while(ch[step]>='0'&&ch[step]<='9')
{
num=num*10+ch[step]-'0';
step++;
}
if (num==0&&ch[step-1]!='0') num=1;
if (ch[step]>='a'&&ch[step]<='z')
{
chunkown=ch[step];
ds=-num;
step++;
}
else sz=-num;
}
else
{
step=0;
num=0;
while(ch[step]>='0'&&ch[step]<='9')
{
num=num*10+ch[step]-'0';
step++;
}
if (num==0&&ch[step-1]!='0') num=1;
if (ch[step]>='a'&&ch[step]<='z')
{
chunkown=ch[step];
ds=num;
step++;
}
else sz=num;
}
nowflag=0;
while (ch[step]!='=')
{
if (ch[step]=='+') nowflag=1; else nowflag=-1;
step++;
num=0;
while(ch[step]>='0'&&ch[step]<='9')
{
num=num*10+ch[step]-'0';
step++;
}
if (num==0&&ch[step-1]!='0') num=1;
if (ch[step]>='a'&&ch[step]<='z')
{
chunkown=ch[step];
ds+=num*nowflag;
step++;
}
else sz+=num*nowflag;
}
step++;
if (ch[step]=='-')
{
step++;
num=0;
while(ch[step]>='0'&&ch[step]<='9')
{
num=num*10+ch[step]-'0';
step++;
}
if (num==0&&ch[step-1]!='0') num=1;
if (ch[step]>='a'&&ch[step]<='z')
{
chunkown=ch[step];
ds+=num;
step++;
}
else sz+=num;
}
else
{
num=0;
while(ch[step]>='0'&&ch[step]<='9')
{
num=num*10+ch[step]-'0';
step++;
}
if (num==0&&ch[step-1]!='0') num=1;
if (ch[step]>='a'&&ch[step]<='z')
{
chunkown=ch[step];
ds-=num;
step++;
}
else sz-=num;
}
nowflag=0;
while (step<strlen(ch))
{
if (ch[step]=='+') nowflag=-1; else nowflag=1;
step++;
num=0;
while(ch[step]>='0'&&ch[step]<='9')
{
num=num*10+ch[step]-'0';
step++;
}
if (num==0) num=1;
if (ch[step]>='a'&&ch[step]<='z')
{
chunkown=ch[step];
ds+=num*nowflag;
step++;
}
else sz+=num*nowflag;
}
ans=(-sz)/ds;
if (sz==0) ans=0;
cout<<chunkown<<"=";
printf("%.3f",ans);
cout<<endl;
return 0;
} -
-12014-08-07 18:42:38@
50题纪念~~~~
-
-12013-11-05 22:08:17@
测试数据 #0: Accepted, time = 15 ms, mem = 564 KiB, score = 17
测试数据 #1: Accepted, time = 15 ms, mem = 564 KiB, score = 22
测试数据 #2: Accepted, time = 0 ms, mem = 564 KiB, score = 22
测试数据 #3: Accepted, time = 0 ms, mem = 564 KiB, score = 22
测试数据 #4: Accepted, time = 0 ms, mem = 560 KiB, score = 17
Accepted, time = 30 ms, mem = 564 KiB, score = 100
代码#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <cstdlib>using namespace std;
int i , j , k;
char s[50];
char x;
int flag;
int a , b , c , d;
int temp;
int head;
float ans;int main()
{
while( scanf( "%s" , &s ) != EOF )
{
temp = 0;
a = b = 0;
c = d = 0;
head = 0;
for( i = 0 ; i < strlen( s ) ; i++ )
if( s[i] >= 'a' && s[i] <= 'z' )
{
x = s[i];
break;
}
flag = 0;
for( i = 0 ; i < strlen( s ) ; i++ )
{
if( s[i] == '=' )
{
flag = 1;
temp = 0;
continue;
}
if( s[i] == x )
{
if( flag == 0 )
{
if( i == 0 )
a += 1;
else if( i == 1 )
if( s[0] == '-' )
a += -1;
else
a += s[0] - '0';
else if( s[i - 1] == '+' )
a += 1;
else if( s[i - 1] == '-' )
a -= 1;
else
for( j = i - 1 ; j >= 0 ; j-- )
if( s[i] == '=' )
{
flag = 1;
temp = 0;
break;
}
else if( s[j] == '+' )
{
for( k = j + 1 ; k < i ; k++ )
{
temp *= 10;
temp += s[k] - '0';
}
a += temp;
temp = 0;
break;
}
else if( s[j] == '-' )
{
for( k = j + 1 ; k < i ; k++ )
{
temp *= 10;
temp += s[k] - '0';
}
a -= temp;
temp = 0;
break;
}
else if( j == 0 )
{
for( k = j ; k < i ; k++ )
{
temp *= 10;
temp += s[k] - '0';
}
a += temp;
temp = 0;
break;
}
temp = 0;
}
else
{
if( i == 0 )
b += 1;
else if( i == 1 )
if( s[0] == '-' )
b += -1;
else
b += s[0] - '0';
else if( s[i - 1] == '+' )
b += 1;
else if( s[i - 1] == '-' )
b -= 1;
else
for( j = i - 1 ; j >= 0 ; j-- )
if( s[j] == '+' )
{
for( k = j + 1 ; k < i ; k++ )
{
temp *= 10;
temp += s[k] - '0';
}
b += temp;
temp = 0;
break;
}
else if( s[j] == '-' )
{
for( k = j + 1 ; k < i ; k++ )
{
temp *= 10;
temp += s[k] - '0';
}
b -= temp;
temp = 0;
break;
}
else if( s[j] == '=' )
{
for( k = j + 1 ; k < i ; k++ )
{
temp *= 10;
temp += s[k] - '0';
}
b += temp;
temp = 0;
break;
}
temp = 0;
}
}}
flag = 0;
temp = 0;
for( i = 0 ; i < strlen( s ) ; i++ )
{
if( s[i] == '=' )
{
flag = 1;
temp = 0;
continue;
}
temp = 0;
if( s[i] == '+' )
for( j = i + 1 ; ; j++ )
{
if( s[j] >= '0' && s[j] <= '9' )
{
temp *= 10;
temp += s[j] - '0';
}
if( s[j] == x )
{
temp = 0;
break;
}
if( s[j] == '+' || s[j] == '-' || s[j] == 0 )
{
if( flag == 0 )
c += temp;
else
d += temp;
temp = 0;
break;
}
else if( s[j] == '=' )
{
if( flag == 0 )
c += temp;
else
d += temp;
flag = 1;
temp = 0;
break;
}
}
else if( s[i] == '-' )
for( j = i + 1 ; ; j++ )
{
if( s[j] >= '0' && s[j] <= '9' )
{
temp *= 10;
temp += s[j] - '0';
}
if( s[j] == x )
{
temp = 0;
break;
}
if( s[j] == '+' || s[j] == '-' || s[j] == 0 )
{
if( flag == 0 )
c -= temp;
else
d -= temp;
temp = 0;
break;
}
else if( s[j] == '=' )
{
if( flag == 0 )
c -= temp;
else
d -= temp;
flag = 1;
temp = 0;
break;
}
}
else if( s[i] == '=' )
for( j = i + 1 ; ; j++ )
{
if( s[j] >= '0' && s[j] <= '9' )
{
temp *= 10;
temp += s[j] - '0';
}
if( s[j] == x )
{
temp = 0;
break;
}
if( s[j] == '+' || s[j] == '-' || s[j] == 0 )
{
if( s[i + 1] == '+' )
d += temp;
else if( s[i + 1] == '-' )
d -= temp;
else
d = temp;
temp = 0;
break;
}
}
else if( head == 0 )
for( j = 0 ; ; j++ )
{
if( s[j] >= '0' && s[j] <= '9' )
{
temp *= 10;
temp += s[j] - '0';
}
if( s[j] == x )
{
temp = 0;
head = 1;
break;
}
if( s[j] == '+' || s[j] == '-' || s[j] == 0 )
{
if( flag == 0 )
c += temp;
else
d += temp;
temp = 0;
head = 1;
break;
}
else if( s[j] == '=' )
{
if( flag == 0 )
c += temp;
else
d += temp;
flag = 1;
temp = 0;
head = 1;
break;
}
}
}
ans = ( d * 1.0 - c * 1.0 ) / ( a * 1.0 - b * 1.0 );
memset( s , 0 , sizeof( s ) );
if( ans != 0 && a != b )
printf( "%c=%.3f\n" , x , ans );
else
cout << x << "=0.000\n";
}
return 0;
} -
-12013-10-22 19:34:48@
哪位大神解释一下,为什么答案会有 -0.000 的出现……
到底是什么样的数据才会使我的 double 产生了-0.000……
求解!!! -
-12013-10-07 13:24:34@
纯模拟就可以过
注意最后一个点,一般是错最后一个点,输出-0.00,标准输出0.00
特判即可
var i,j,k,l,n,m,p,ans,get,zz:longint;
s:string;
f:boolean;
a1,b1:longint;
an:real;
w:char;function solve(left,right:longint):longint;
var ans1:longint;
q:longint;
a:array[0..10000] of longint;
begin
fillchar(a,sizeof(a),0);
ans1:=0;
for i:=left to right do begin
case s[i] of
'+':begin
inc(q);
a[q]:=0;
f:=false;
end;
'-':begin
f:=true;
inc(q);
a[q]:=0;
end;
'*':begin
inc(q);
a[q]:=0;
p:=0;
f:=false;
end;
'0','1','2','3','4','5','6','7','8','9':if f then a[q]:=a[q]*10-ord(s[i])+48
else a[q]:=a[q]*10+ord(s[i])-48;
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
'r','s','t','u','v','w','x','y','z':begin
w:=s[i];
inc(zz);
if zz>1 then ans:=-a[q]+ans
else ans:=a[q]+ans;
a[q]:=0;
end;
end;
end;
for i:=1 to q do ans1:=ans1+a[i];
solve:=ans1;
end;begin
readln(s);
l:=length(s);
get:=pos('=',s);
a1:=solve(1,get-1);
b1:=solve(get+1,l);
an:=(b1-a1)/(ans);
if an=0 then writeln(w,'=0.000')
else
writeln(w,'=',an:0:3);
end. -
-12013-04-28 20:24:51@
VijosEx via JudgeDaemon2/13.4.6.0 via libjudge
编译成功测试数据 #0: Accepted, time = 10 ms, mem = 728 KiB, score = 17
测试数据 #1: Accepted, time = 2 ms, mem = 728 KiB, score = 22
测试数据 #2: Accepted, time = 4 ms, mem = 728 KiB, score = 22
测试数据 #3: Accepted, time = 3 ms, mem = 724 KiB, score = 22
测试数据 #4: Accepted, time = 2 ms, mem = 724 KiB, score = 17
Accepted, time = 24 ms, mem = 728 KiB, score = 100
。。。多打了一个“·” -
-12013-04-28 20:23:11@
VijosEx via JudgeDaemon2/13.4.6.0 via libjudge
编译失败(CompileError)foo.pas(84,21) Fatal: illegal character "'`'" ($60)
Fatal: Compilation aborted
Error: C:\FPC\2.6.2\bin\i386-win32\ppc386.exe returned an error exitcode (normal if you did not specify a source file to be compiled)
CompileError, time = 0 ms, mem = 0 KiB, score = 0 -
-12013-04-28 20:22:08@
const unknown=['a'..'z'];
run=['+','-'];type a=record
x:integer;
n:integer;
end;var x:char;i:integer;
t,t1,t2:string;
s1,s2,s:a;function hebing(t:string):a;
var t1,t2,temp:string;function position(var s:string):string;
//copy from first in run to second in run
var i,pos1,pos2:integer;
begin
for i:=1 to length(s) do
if s[i] in run then begin
pos1:=i;
break;
end;
if pos1=length(s) then begin
position:='';
exit;
end;
for i:=pos1+1 to length(s) do
if s[i] in run then begin
pos2:=i;
break;
end;
position:=copy(s,pos1,pos2-1);
delete(s,pos1,pos2-pos1);
end;function running(s:string):integer;
//calculate
var temp,code:integer;
temp2:string;
begin
s:=s+'+';
running:=0;
temp2:=position(s);
while temp2<>'' do begin
val(temp2,temp,code);
running:=running+temp;
temp2:=position(s);
end;
end;begin
t1:='';t2:='';
temp:=position(t);
while temp<>'' do begin
if pos(x,temp)=0
then t1:=t1+temp
else t2:=t2+temp;
temp:=position(t);
end;
while pos(x,t2)<>0 do delete(t2,pos(x,t2),1);
hebing.x:=running(t2);
hebing.n:=running(t1);
end;begin
while not eof do begin
readln(t);
t1:=copy(t,1,pos('=',t)-1);
t2:=copy(t,pos('=',t)+1,length(t));
for i:=1 to length(t) do if t[i] in unknown then begin
x:=t[i];
break;
end;
if t1[1]<>'-' then t1:='+'+t1;
if t2[1]<>'-' then t2:='+'+t2;
t1:=t1+'+';
t2:=t2+'+';
s1:=hebing(t1);
s2:=hebing(t2);
s.x:=s1.x-s2.x;
s.n:=s2.n-s1.n; `
writeln(x,'=',s.n/s.x:0:3);
end;
end.
此题提交后compile error,应该没问题的。。。 -
-12010-04-09 23:21:12@
的确很诡异,要判断-0.000
-
-12009-09-07 20:47:50@
本来不打算做出来的……结果“二次方程”那题居然过了~
于是改了改~hoho#include
#include
#include
using namespace std;
int main()
{
char s1[300],s2[300];
char lett;
scanf("%[^=]=%s",s1,s2);
int coef=1;int tomul=1;bool dirt=false;
int c[2]={0};
for (int i=0;i='a' && s1[i]='0' && s1[i]