北航上机测试准备 程序2

/*
//1
#include<stdio.h>
#include<stdlib.h>
void main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int found=0;
int i,j,k;
for(i=1;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if((i+j)*(j-i+1)/2==n)
{
found=1;
for(k=i;k<=j;k++)
{
printf("%d ",k);
}
if(found==1) printf("\n");
}
}
}
if(found==0)  printf("NONE\n");
}
}
*/


/*
//2
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void main()
{
int n;
int sum=0;
scanf("%d",&n);
int island[100][100];
int i,j;
int data[100][4];
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&island[i][j]);
}
}
memset(data,-1,100*4*sizeof(data));
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(island[i][j]==1)
{
if(data[i][0]==-1)
data[i][0]=j;
if(data[j][2]==-1)
data[j][2]=i;
data[i][1]=j;
data[j][3]=i;
}
}
}
int area=0;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(island[i][j]==0)
{
if(i>data[j][2]&&i<data[j][3]&&j>data[i][0]&&j<data[i][1])
{
area++;
}
}
printf("%d\n",area);
}
*/


/*
//3
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void replaceQuota(char buf[])
{
int i;
int len=strlen(buf);
int quotaL=0,quotaR=0;
for(i=0;i<len;i++)
{
if(buf[i]=='"')
{
if(quotaL==0)
quotaL=1;
else quotaL=quotaR=0;
}
else
{
if(quotaL==1) buf[i]='#';
}
}
}
int isdelim(char ch)
{
switch(ch)
{
case' ':
case'=':
case',':
case';':
case'<':
case'>':
case'(':
case')':
case'[':
case']':
case'{':
case'}':return 1;
default:return 0;
}
}
int getWord(char input[],int pos,char word[])
{
int len=strlen(input);
int i;
int isbegin=0;
int wpos=0;
for(i=pos;i<len;i++)
{
if(isdelim(input[i]))
{
if(isbegin==0)
continue;
else break;
}
else
{
isbegin=1;
word[wpos++]=input[i];
}
}
word[wpos]='\0';
return (i>=len)?-1:i;
}
void main()
{
char input[300];
char word[300];
while(gets(input)!=NULL)
{
replaceQuota(input);
int beg_pos=0;
do
{
beg_pos=getWord(input,beg_pos,word);
int wlen=strlen(word);
if(strcmp("if",word)==0)
{
printf("if:%d\n",beg_pos-wlen+1);
}
else if(strcmp("while",word)==0)
{
printf("while:%d\n",beg_pos-wlen+1);
}
else if(strcmp("for",word)==0)
{
printf("for:%d\n",beg_pos-wlen+1);
}
}
while(beg_pos>=0);
}
}
*/




//11
/*
//3
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char str[100];
scanf("%s",str);
int i,j;char k;
for(i=0;i<strlen(str);i++)
{
if(str[i]=='-')
{
if(str[i-1]>='a'&&str[i-1]<='z'&&str[i+1]>='a'&&str[i+1]<='z'||str[i-1]>='A'&&str[i-1]<='Z'&&str[i+1]>='A'&&str[i+1]<='Z'
||str[i-1]>='0'&&str[i-1]<='9'&&str[i+1]>='0'&&str[i+1]<='9')
{
for(k=str[i-1]+1;k<str[i+1];k++)
printf("%c",k);
}
else printf("%c",str[i]);
}
else printf("%c",str[i]);
}
printf("\n");


}
*/




/*
//2
#include<stdio.h>
#include<stdlib.h>
int yinzisum(int x)
{
int i=1,sum=0;
if(x==1) return 0;
while(i<x)
{
if(x%i==0)
sum=sum+i;
i++;
}
return sum;
}
void main()
{
int x,y,flag=0,i,j;
scanf("%d%d",&x,&y);
int min,max;
if(x>y) { max=x;min=y;}
else { max=y; min=x;}
int *array=(int*)malloc(sizeof(int)*(max-min+1));
for(i=0;i<max-min+1;i++)
array[i]=yinzisum(min+i);
for(i=0;i<max-min+1;i++)
for(j=i+1;j<max-min+1;j++)
if(array[i]==j+min&&array[j]==i+min){
printf("%d %d\n",i+min,j+min);
flag=1;
}
if(flag==0)  printf("NONE");
}
*/


//10
/*
//2
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
void main()
{
char str1[300],str2[300];
gets(str1);
gets(str2);
int i,j,k;
int num1=strlen(str1);
int num2=strlen(str2);
int num3=num2;
int buf[100];//保存i值
memset(buf,0,sizeof(buf));
for(i=0;i<num1;i++)
{
for(j=0;j<num2;j++)
{
if(str1[i]==str2[j])
{
buf[i]=1;
}
}
}
for(i=0;i<num1;i++)
{
if(buf[i]==0)
{
str2[num3++]=str1[i];
}
}
str2[num3]='\0';
std::sort(str2,str2+num3);
for(i=0;i<num3;i++)
printf("%c",str2[i]);
printf("\n");
}


*/
/*
//3
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
void main()
{
char str1[100];
char str2[100];
scanf("%s",&str1);
scanf("%s",&str2);
int num1=strlen(str1);
int num2=strlen(str2);
std::sort(str1,str1+num1);
std::sort(str2,str2+num2);
int i,j;
for(i=0;i<num1;i++)
{
if(str1[i]!=str2[i]){
printf("no\n");}
}
}
*/
//09


/*
//1
#include<stdio.h>
#include<stdlib.h>
double y(int n,double x)
{
if(n==0) return x;
else return y(n-1,x)*2/3+x/(3*y(n-1,x)*y(n-1,x));
}
void main()
{
int n;
int i;
double x,y;
while(scanf("%lf",&x)!=EOF)
{
scanf("%d",&n);
//printf("%.6lf",y(n,x));
y=x;
for(i=1;i<=n;i++)
y=y*2/3+x/(3*y*y);
printf("%.6f\n",y);
}
}
*/


/*
//2
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
void main()
{
char str1[100];
char str2[100];
scanf("%s",&str1);
int i,j,k;
int num;


// while(scanf("%s",str1)!=EOF)
// {
for(i=0;i<num;i++) str2[i]=str1[i];
num=strlen(str1);
std::sort(str1,str1+num);
for(k=0;k<num;k++)
{
for(j=0;j<num;j++)
{
if(str2[k]==str1[j])  
{
printf("%d ",j);
// continue;
}
}
}
printf("333333333333\n");
// }
}
*/


/*
//3
#include<stdio.h>
#include<string.h>
#include<ctype.h>
void main()
{
char a[100];
int i,n,j;
char c;
scanf("%s",a);
n=strlen(a);
i=0;
c=getchar();
while((c=getchar())!=EOF)
{
if(tolower(c)==tolower(a[i]))
{
i++;
if(i>=n)
i=0;
}
else
{
if(i==0)
{
if(c!='') putchar(c);
}
else
{
for(j=0;j<i;j++)
putchar(a[j]);
i=0;
if(c!='') putchar(c);
}
}
}
}
*/




#include<stdio.h>
int judge(int a[9][9],int b[9][9],int n)
{
int i,j,count=0;
if(a[0][0]==b[0][0]&&a[0][n-1]==b[0][n-1]
&&a[n-1][0]==b[n-1][0]&&a[n-1][n-1]==b[n-1][n-1])
{
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
if(a[i][j]==b[i][j]) count++;
}
if(count==n*n) return 0;
else return -1;
}
else if()
{
for()
for()
{
if()
}
if(count==n*n) return 90;
   else return -1;
}
else if
{


}
else if
{


}
}
int main()
{
int n,i,j,a[9][9],b[9][9];
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&b[i][j]);
printf("%d"\n",judge(a,b,n));
}
}







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值