119 条题解

  • 0
    @ 2009-05-10 03:04:39

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    #include "stdio.h"

    #include "ctype.h"

    int main()

    {

    int num=0,temp=0,word=0,fuhao=-1,i=0,k=1;

    char a,fanchen[100];

    scanf("%s",fanchen);

    while(fanchen[i]!='\0')

    {

    if(isdigit(fanchen[i]))

    temp=temp*10+fanchen[i]-'0';

    if(fanchen[i]=='+')

    {

    num+=temp*fuhao*k;

    temp=0;k=1;

    }

    if(fanchen[i]=='-')

    {

    num+=temp*fuhao*k;

    temp=0;k=-1;

    }

    if(fanchen[i]=='=')

    {

    num+=temp*fuhao*k;

    temp=0;fuhao=1;k=1;

    }

    if(isalpha(fanchen[i]))

    {

    if(temp!=0)

    {

    word+=-(temp*fuhao*k);

    a=fanchen[i];temp=0;

    }

    else

    {

    word+=-1*fuhao*k;

    a=fanchen[i];

    temp=0;

    }

    }

    i++;

    }

    printf("%c=%.3f",a,(((float)temp*k*fuhao+(float)num)/(float)word));

    return 0;

    }

  • 0
    @ 2009-04-02 17:23:21

    本人贡献一下源代码`\`\

    var

    s:string;

    s1,s2:string;

    xx,shu,xx2,shu2:longint;

    i,j,k,l,m,n,p:longint;

    c:char;

    procedure go(ss:string; var a,b:longint);

    var

    i,j,p,j1,j2,w,f:longint;

    begin

    p:=1;

    repeat

    f:=1;

    j1:=0;

    if ss[p]='-' then begin f:=-1; inc(p); end else

    if ss[p]='+' then inc(p);

    if ss[p]=c then j1:=1;

    while (p

  • 0
    @ 2009-03-03 21:55:56

    /*by visual studio 2005

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    */

    #include

    using namespace std;

    void print_with_dot_3(double x)

    {

    if(x

  • 0
    @ 2009-02-05 19:30:41

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    var

    i,j,k,n,m,w,v,vvv,vv,sssssssssss:longint;

    jie:extended;

    a,b:array[0..100]of longint;

    s,c,aw:string;

    q:char;

    ss,s1:array[0..100]of string;

    begin

    readln(s);

    for i:=1 to length(s) do

    begin

    if (s[i]>='a')and(s[i]n then j:=j-v else j:=j+v; end

    else begin val(c,v); if i>n then j:=j+v else j:=j-v; end;

    end

    else begin

    for vv:=1 to length(c) do

    if c[vv]=q

    then begin aw:=copy(c,1,vv-1); val(aw,v);

    if s[w]='+'

    then begin if i>n then k:=k-v else k:=k+v; end

    else begin if i>n then k:=k+v else k:=k-v; end;

    end;

    end;

    if s[i]'='

    then w:=i

    else w:=i+1;

    end;

    end;

    jie:=-j/k;

    write(q,'=',jie:0:3);

    end.

    53 行代码 久违的1次AC!!

  • 0
    @ 2009-01-30 22:28:32

    3次ac

    110行代码,至少10行是空行

    用了过程的嵌套

    其实没这么复杂

    我故意拆成一段一段的

    就当练习了,呵呵

    里面的special过程是ac重点

    如果不愿都看就看这一段吧

    var

    s:string;

    c:char;

    x,y:integer;

    procedure sum(s:string;var c:char;var x,y:integer);

    var

    s1,s2:string;

    x1,x2,y1,y2:integer;

    function getx(s:string):char;

    var

    i:integer;

    begin

    for i:=1 to length(s) do

    if not(s[i] in ['+','-','=','0'..'9'])

    then exit(s[i]);

    end;

    procedure cut(s:string;var s1,s2:string);

    begin

    s1:=copy(s,1,pos('=',s)-1);

    s2:=copy(s,pos('=',s)+1,length(s)-pos('=',s));

    end;

    procedure make(var s:string;c:char);

    procedure insertspace(var s:string);

    var

    i:integer;

    begin

    i:=2;

    while i

  • 0
    @ 2009-01-29 16:12:09

    Var

    str,str1,str2,strr1:string;

    chr:char;

    i,posa,posb,pos1,pos2,num,code,xx,nn:longint;

    Begin

    readln(str);

    pos1:=pos('=',str);

    str1:=copy(str,1,pos1-1);

    if str1[1]'-' then str1:='+'+str1;

    str2:=copy(str,pos1+1,length(str));

    if str2[1]'-' then str2:='+'+str2;

    for i:=1 to length(str) do

    if str[i] in ['a'..'z'] then begin chr:=str[i];break;end;

    while str1'' do

    begin

    if str1[1]='+' then

    begin

    delete(str1,1,1);

    posa:=pos('+',str1);

    posb:=pos('-',str1);

    if ((posa

  • 0
    @ 2009-01-23 12:34:30

    凭什么最后一个错误,自己测试是"a=0.000",郁闷

    #include "stdio.h"

    #include "ctype.h"

    main()

    {int num=0,temp=0,word=0,fuhao=-1,i=0,k=1;

    char a,fanchen[100];

    scanf("%s",fanchen);

    while(fanchen[i]!='\0'){

    if(isdigit(fanchen[i]))

    temp=temp*10+(fanchen[i]-48);

    if(fanchen[i]=='+'){

    num+=temp*fuhao*k;

    temp=0;k=1;}

    if(fanchen[i]=='-'){

    num+=temp*fuhao*k;

    temp=0;k=-1;}

    if(fanchen[i]=='='){

    num+=temp*fuhao*k;

    temp=0;fuhao=1;k=1;

    }

    if(isalpha(fanchen[i])){

    if(temp!=0)

    {

    word+=-(temp*fuhao*k);

    a=fanchen[i];temp=0;

    }

    else

    {

    word+=-(1*fuhao*k);

    a=fanchen[i];temp=0;

    }

    }

    i++;

    }

    printf("%c=%.3f",a,(((float)temp*k*fuhao+(float)num)/(float)word));

    }

  • 0
    @ 2009-01-13 16:33:56

    #include

    #include

    int main() {

    char s[100],*p,*p2,*eq,let;

    int a=0,b=0,i;

    gets(s);

    eq=strchr(s,'=');

    let=*strpbrk(s,"abcdefghijklmnopqrstuvwxyz");

    p=p2=s;

    while(p2

  • 0
    @ 2008-12-11 17:29:00

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    var st,stl,str,va:string;

    i,l,j,k,la:integer;

    rn,rvn,ln,lvn:integer;

    procedure make(st:string;var nu,vnu:integer);

    var i,l,num,code,l1:integer;

    st1,st2:string;

    op:char;

    begin

    st:=st+'\(';
    nu:=0;
    vnu:=0;
    if st[1] '-' then st:='+'+st;
    repeat
    i:=2;
    l:=length(st);
    while not(st[i] in ['+','-','\)']) do inc(i);

    op:=st[1];

    dec(i);

    st1:=copy(st,2,i-1);

    st:=copy(st,i+1,l-i);

    val(st1,num,code);

    if code = 0 then

    begin

    if op='+' then nu:=nu+num;

    if op='-' then nu:=nu-num;

    end

    else

    begin

    l1:=length(st1);

    if st1 = va then

    begin

    if op='+' then vnu:=vnu+1;

    if op='-' then vnu:=vnu-1;

    end

    else

    begin

    st2:=copy(st1,1,l1-la);

    val(st2,num,code);

    if op='+' then vnu:=vnu+num;

    if op='-' then vnu:=vnu-num;

    end;

    end;

    until st='$';

    end;

    begin

    readln(st);

    l:=length(st);

    i:=1;

    while st[i] '=' do inc(i);

    stl:=copy(st,1,i-1);

    str:=copy(st,i+1,l-i);

    i:=1;

    while st[i] in ['0'..'9','+','-','='] do inc(i);

    j:=1;

    while not (st in ['0'..'9','+','-','=']) do inc(j);

    va:=copy(st,i,j-1);

    la:=length(va);

    make(stl,ln,lvn);

    make(str,rn,rvn);

    if ( rn - ln) = 0 then writeln(va,'=0.000')

    else

    writeln(va,'=',(rn-ln) / (lvn-rvn) :0:3);

    end.

    3遍.....

  • 0
    @ 2008-12-03 19:50:42

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    水题!水题!水题!水题!水题!水题!一次AC

    细节活,基本字符串处理

  • 0
    @ 2008-11-09 11:17:24

    前两个没有回车??

  • 0
    @ 2008-11-08 10:21:19

    program improvement;

    var

    s,s1,s2:string;

    i,k,p,n:longint;

    ch,cc:char;

    j,x,c:extended;

    begin

    readln(s);

    k:=pos('=',s);

    s1:=copy(s,1,k-1);

    s2:=copy(s,k+1,length(s)-k);

    for cc:='a' to 'z' do

    if pos(cc,s)0 then

    begin

    ch:=cc;break;

    end;

    if (s1[1]'+')and(s1[1]'-')    then insert('+',s1,1);

    while s1'' do

    begin

    k:=2;

    while (s1[k]'+')and(s1[k]'-')and(k

  • 0
    @ 2008-11-07 21:27:41

    把原方程化为:ax+b=cx+d or ax+b=0,

    然后就简单了。

    注意(a-c=0)和或(d-b=0)时的情况!!!!

  • 0
    @ 2008-11-04 11:52:57

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

  • 0
    @ 2008-11-04 11:35:24

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    var

    sign:char;

    j,i,lcx,lc0,rcx,rc0:longint;

    st,l,r:string;

    procedure make(ex:string;var cx,c0:longint);

    var

    i,c:longint;

    flag:boolean;

    item:string;

    begin

    i:=1;cx:=0;c0:=0;

    while ilength(ex))or(ex[i]='+')or(ex[i]='-');

    if (c=0)and(not(exin['0'..'9']))and(ex'0')then c:=1;

    if(ex>='0')and(ex

  • 0
    @ 2008-11-03 11:42:50

    居然忽略了一个极简单的事实 ...

    a 的系数是 1 ....

  • 0
    @ 2008-11-02 21:59:48

    虽然难度只有1 ,但却让我掉了3%的AC。

    最后1个点输成-0.000了…………

    然后改又改错了………………

  • 0
    @ 2008-10-29 11:37:40

    #include

    #include

    using namespace std;

    main(){

    int i,s,ss=0,xs=0,x1,x2,length;

    float m;

    //freopen("equation.in","r",stdin);

    //freopen("equation.out","w",stdout);

    char a[301],c;

    scanf ("%s",&a);

    length=strlen(a);

    i=0;

    while(a[i]!='=')

    {s=0;

    x1=1;

    if(a[i]>='a' && a[i]='0' && a[i]='a' && a[i]='0' && a[i]='a' && a[i]

  • 0
    @ 2008-10-23 21:27:33

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    扫一遍,完事

  • 0
    @ 2008-10-13 22:58:45

    var

    s,s1,s2:string;

    i,k,p,n:longint;

    ch,cc:char;

    j,x,c:extended;

    begin

    readln(s);

    k:=pos('=',s);

    s1:=copy(s,1,k-1);

    s2:=copy(s,k+1,length(s)-k);

    for cc:='a' to 'z' do

    if pos(cc,s)0 then

    begin

    ch:=cc;break;

    end;

    if (s1[1]'+')and(s1[1]'-') then insert('+',s1,1);

    while s1'' do

    begin

    k:=2;

    while (s1[k]'+')and(s1[k]'-')and(k

信息

ID
1344
难度
5
分类
模拟 点击显示
标签
递交数
2927
已通过
1018
通过率
35%
被复制
18
上传者