(;n<=50000;n++)
{
sum1+=1/n;
}
for(n=50000;n>0;n--)
{
sum2+=1/n;
}
JOptionPane.showMessageDialog(null,"从左往右: "+sum1+"\n"+"从右往左:"+sum2);
}
}*/
//4.25
/*
public class LQ
{
public static void main(String[]args)
{
double i;
double sum=0;
StringBuffer s=new StringBuffer("");
for(i=1;i<=100000;i++)
{
sum=sum+(int)(Math.pow(-1, i+1))*1/(2*i-1);
if(i==10000||i==20000||i==30000||i==40000||i==50000||i==60000||i==70000||i==80000||i==90000||i==100000)
{
s.append(sum*4+"\n");
}
}
JOptionPane.showMessageDialog(null,s);
}
}*/
//4.26
/*
public class LQ
{
public static void main(String[]args)
{
double i=1,sum=1,t=1;
StringBuffer s=new StringBuffer("");
for(;i<=100000;i++)
{
sum=sum+t/i;
t=t/i;
if(i==10000||i==20000||i==30000||i==40000||i==50000||i==60000||i==70000||i==80000||i==90000||i==100000)
{
s.append(sum+"\n");
}
}
JOptionPane.showMessageDialog(null,s);
}
}
*/
//4.27
/*
public class LQ
{
public static void main(String []args)
{
StringBuffer s=new StringBuffer("");
for(int j=0,i=2001;i<=2100;i++)
{
if((i%4==0&&i%100!=0)||i%400==0)
{
s.append(i+" ");
j++;
}
if(j==10)
{
s.append("\n");
j=0;
}
}
JOptionPane.showMessageDialog(null,s);
}
}*/
//4.28
/*
public class LQ
{
static String s1(int m)
{
String s="";
if(m==1){s="Monday";}
if(m==2){s="Tuesday";}
if(m==3){s="Wednesday";}
if(m==4){s="Thursday";}
if(m==5){s="Friday";}
if(m==6){s="Saturday";}
if(m==0){s="Sunday";}
return s;
}
public static void main(String []args)
{
String s1=JOptionPane.showInputDialog("请输入年份");
String s2=JOptionPane.showInputDialog("请输入一月一日是星期几");
StringBuffer s=new StringBuffer("");
int i1=Integer.parseInt(s1);
int i2=Integer.parseInt(s2);
int D = 0;
if((i1%4==0&&i1%100!=0)||i1%400==0)
{
int i=1;
switch(i)
{
case 1:{s.append("January 1,"+i1+" is "+s1(i2%7)+"\n");D=31+i2;}
case 2:{s.append("February 1,"+i1+" is "+s1(D%7)+"\n");D+=29;}
case 3:{s.append("march 1,"+i1+" is "+s1(D%7)+"\n");D+=31;}
case 4:{s.append("April 1,"+i1+" is "+s1(D%7)+"\n");D+=30;}
case 5:{s.append("may 1,"+i1+" is "+s1(D%7)+"\n");D+=31;}
case 6:{s.append("June 1,"+i1+" is "+s1(D%7)+"\n");D+=30;}
case 7:{;s.append("July 1,"+i1+" is "+s1(D%7)+"\n");D+=31;}
case 8:{s.append("August 1,"+i1+" is "+s1(D%7)+"\n");D+=31;}
case 9:{s.append("September 1,"+i1+" is "+s1(D%7)+"\n");D+=30;}
case 10:{s.append("October 1,"+i1+" is "+s1(D%7)+"\n");D+=31;}
case 11:{s.append("November 1,"+i1+" is "+s1(D%7)+"\n");D+=30;}
case 12:{s.append("December 1,"+i1+" is "+s1(D%7)+"\n");D+=31;}
default:break;
}
}
else
{
int i=1;
switch(i)
{
case 1:{s.append("January 1,"+i1+" is "+s1(i2%7)+"\n");D=31+i2