博文
stu(1154)(2005-08-30 20:18:00)
摘要:#include<iostream.h>
int main()
{
int k,i,j,t_case,t_piont,count;
int x[1000],y[1000];
cin>>t_case;
if((t_case<1)&&(t_case>1000)) return 0;
for(k=0;k<t_case;k++)
{
count=0;
cin>>t_piont;
for(i=0;i<t_piont;i++)
{
cin>>x[i]>>y[i];
if((x[i]<-10000)&&(x[i]>10000)&&(y[i]<-10000)&&(y[i]>10000))
return 0;
&nbs......
stu(1101)(2005-08-30 20:17:00)
摘要:#include<stdio.h>
#include<iostream.h>
int main()
{
int n[15],i=0,j,twice=0;
cin>>n[i];
while(n[i]!=-1)
{
cin>>n[++i];
if(n[i]==0)
{
cout<<twice<<endl;
twice=0;
i=0;
cin>>n[i];
}
else
{
for(j=0;j<i;j++)
{
if(n[j]==2*n[i]||n[i]==2*n[j])
twice++;
&nbs......
stu(1059)(2005-08-30 20:16:00)
摘要:#include"iostream.h"
void print(int *data,int n)
{
int i;
int a,b;
//-----判断前面有没有相同的点,如果有,则从第二个起将所有的点前移,并将点的总数n减1-----
while(data[2]==data[0]&&data[3]==data[1])
{
for(i=0;i<2*n-2;i++) data[i]=data[i+2]; //前移
n--; //总数减1
}
 ......
stu(1030)(2005-08-30 20:15:00)
摘要:这是汕头大学的第1030道题,答案:
#include<stdio.h>
#include<string.h>
int change(char C[],int k)
{
int i;
for(i=0;i<k;i++)
{
if(C[i]/10)
{
C[i]=C[i]%10;
C[i+1]++;
}
}
if(C[i])
k++;
return k;
}
int main()
{
char A[52],B[52],C[52];
&nb......
stu(1027)(2005-08-30 20:14:00)
摘要:#include<stdio.h>
#include<stdlib.h>
long check(long r)
{ long x=1;
while((r/2)%2==0)
{ x++;
r=r/2;
}
if(r!=1)
return(0);
else
return(x);
}
long count(long n)
{ int k=1;
while(!check(k*n+1))
k++;
}
int main()
{ long n,x;
while(scanf("%ld",&n)!=EOF)
{ if(n==1||n%2==0)
printf("2^? mod %ld=1\n",n);
else
{ x=count(n);
printf("2^%ld mod %ld=1\n",x,n);
}
}
return 0;
......
stu(1021)Z(2005-08-30 20:12:00)
摘要:这题是汕头大学的1021道题:答案是:
#include<stdio.h>
#include<stdlib.h>
int change()
{ char x;
int sum=0;
scanf("%c",&x);
if(x!='0')
{ do
{ sum=sum+x-48;
scanf("%c",&x);
}while(x>=48);
}
else
return(0);
return(sum);
}
int root(long x)
{ int sum=0;
while(x>9)
{ sum=sum+x%10;
x=x/10;
}
return(sum+x);
}
int main()
{ int x;
x=change();
while(x)
{
do
{ x=root(x);
}while(x>9);
printf("%d\n",x);
x=change();
}......
pku(2591)(2005-08-28 14:10:00)
摘要:#include <iostream.h>
#include <stdio.h>
long a[10000002];
long min(long a,long b)
{
if(a<b) return a;
else
return b;
}
int main()
{
long i,j;
long n,k;
i=1,j=1;
a[1]=1;
for(k=2;k<=10000001;k++)
{
a[k]=min(2*a[i]+1,3*a[j]+1);
if(2*a[i]+1==a[k])
i++;
if(3......
jnu(String Matching)(2005-08-27 16:00:00)
摘要:#include <iostream.h>
#include <fstream.h>
ifstream f("String.in");
#define cin f
#include <string.h>
int main()
{
char a[1000],b[1000],temp[1000];
while(cin>>a)
{
int total=0;
int sum,i,j,k;
if(strcmp(a,"-1")==0) return 0;
cin>>b;
cout<<"appx("<<a<<","<<b<<") = ";
if(strlen(a)<strlen(b))
{
strcpy(temp,a);
&nb......
jnu(Function Run Fun)(2005-08-27 16:00:00)
摘要:#include <math.h>
#include <iostream.h>
int w(int a,int b,int c)
{
if(a<=0 || b<=0 || c<=0)
return 1;
else if(a>20 || b>20 || c>20)
return w(20,20,20);
else if(a==b && c==b)
return (int)pow(2,a);
else if((a<=b && a<=c) || (a<=c && b<=c) || (b>=a && b>=c))
return (int)pow(2,a);
else
return w(a-1, b, c) + w(a-1, b-1, c) + w(a-1, b, c-1) - w(a-1, b-1, c-1) ;
}
int main()
{
int a,b,c;
while(cin>>a>>b>>c)
{
&n......
jnu(Partial Sums)(2005-08-26 14:48:00)
摘要:#include <iostream.h>
#include <fstream.h>
ifstream f("e.in");
#define cin f
int main()
{
int n,m;
int a[10000];
int b[5000];
int i,j;
int sum=0,total;
while(cin>>n>>m)
{
for(i=0;i<m;i++)
b[i]=0;
sum=total=0;
for(i=0;i<n;i++)
cin>>a[i];
for(i=0;i<n;i++)
{
sum+=a[i];
......