1.	
program  exp1  (imput,output);                                         {6%}
    VAR  i,  s,  max: integer;
          a    :array [1..10]  of  integer;
        begin 
          for i:=1 to 10  do   read (a[i]);
          max:=a[1] ;s:=a[1];
          for i:=2  to  10  do 
            begin 
              if  s<0  then  s:=0;                
              s:= s+a[i];                        
           if s>max  then  max:=s
        end;
     writeln(‘max=’, MAX)
 end.  
      输入:8  9  -1  24  6  5  11  15  -28  9      
输出:max=77			
				
							  
							 
				
			
		 	
			
		
			
							 
				2.	
program  exp3 (input,output);                                         {9%}
     CONST  N=10;
VAR S,I : INTEGER;
FUNCTION  CO(I1:INTEGER) : INTEGER;
   VAR J1,S1 : INTEGER;                           
 BEGIN                                          
   S1:=N;
     FOR J1:= (N-1)  DOWNTO  (N-I1+1)  DO       
     S1:= S1*J1  DIV  (N-J1+1);                
     CO:=S1
   END;
BEGIN                                      
  S:=N+1;                                    
  FOR I:= 2  TO  N  DO  S:=S + CO(I);
       WRITELN(‘S=’,S);
END.
输出:S=1024			
				
							  
							 
				
			
		 	
			
		
			
							 
				3.	
program  exp3(input,output);                                          {12%}
VAR I,J,S:INTEGER;
     B    :ARRAY[0..5]  OF  INTEGER;
     BEGIN
   S:=1;
   FOR I:=1  TO  5  DO   B[I]:=I   
   J:=1;
   WHILE  J>0  DO
       BEGIN
          J:=5;
          WHILE  (J>0) AND (B[J]=10+J-5) DO 
            J:=J-1;
       IF J>0 THEN  BEGIN
                      S:=S+1;  B[J]:=B[J]+1;
                      FOR I:=J+1 TO 5 DO  B[I]:=B[J]+I-J
                    END;
 END;
       WRITELN('S=',S);
     END.
输出:S=252			
				
							  
							 
				
			
		 	
			
		
			
							 
				4.	
Program  EXP4 (input,output);                                        {12%}
        const n=4;
type  se=array[1..n*2] of char;
var   i,j,i1,j1,k,s,t,s1,l,swap:integer;
       temp    :char;
       a       :se;
begin
  for  i:=1  to  n*2  do   read(a[i]);  readln;      
  s:=0;  t:=0;                                            
  for i:=1 to n*2 do                                    
            if a[i]='1' then s:=s+1 
                  else if a[i]='0' then t:=t+1;
          if  (s<>n)  or  (t<>n)  then  writeln('error')
             else  begin 
                    s1:=0;
                    for i:=1 to 2*n-1  do  if a[i]<>a[i+1] then s1:=s1+1;
                    writeln('jamp=',s1);  swap:=0;
             
 for i:=1 to 2*n-1 do
                     for j:=i+1 to 2*n do
                     if a[i]<>a[j] then begin
                           temp:=a[i];a[i]:=a[j] ;a[j]:=temp;
                           s:=0;
                           for l:=1 to 2*n-1 do
                               if a[l]<>a[l+1]  then  s:=s+1;
if s>swap  then  begin 
                   swap:=s;  i1:=i;  j1:=j  
                 end;
                           temp:=a[i]; a[i]:=a[j]; a[j]:=temp
                       end;
                 if  swap>0  then  writeln('maxswap=',swap-s1,' i=',i1,' j=',j1)
              end
       END.
  输入:10101100
输出:jamp=5 maxswap=2 i=6 j=7