This presentation is the property of its rightful owner.
Sponsored Links
1 / 61

上机考试复习 PowerPoint PPT Presentation


  • 92 Views
  • Uploaded on
  • Presentation posted in: General

上机考试复习. 一、上机考试事项. 考试范围:条件判断、循环、数组、函数。 考试题型:程序填空题。与实验题完全相同 考试日期: 6 月 7 日 14:00-15:10 考试时间: 1 小时 4 题 带学生证或有效证件(有学号和照片的证件) 带上机卡 , 刷卡进入 ( 上机卡卡内余额不能为负值 ) 只能带文具入场和一张 A4 草稿纸 补考时间: 6 月 7 日 17:00-18:10. 注 : 如果考试时间冲突 ( 下午微积分 I), 请让学生在下周四 10:00--11:00,12:30--15:30 到计算中心 316 登记. 二、上机考试系统操作.

Download Presentation

上机考试复习

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


4644743

6714:00-15:10

14

,()

A4

6717:00-18:10

:(I),10:00--11:00,12:30--15:30316.


4644743

1.

delWindows,E()

10.71.5.8()

VC

.c

.c


4644743

2.

(1)/,,50008,printf("%d ", i).

(2)

(3)

.c

VC++

.c

(4) ,

VC++temp

(5) repeat#,##


4644743

repeat (0<repeat<10)repeat

n, n

3 (repeat=3)

4 2 123 -100 0

4 9 1 -1 8

3 1 3 5

123

9

5

#include <stdio.h>

int main( )

{

int ri, repeat;

int i , max, n, x;

scanf("%d", &repeat);

for(ri=1; ri<=repeat; ri++){

scanf("%d", &n);

/*---------*/

printf("%d\n", max);

}

}


4644743

# (80) ## (0)Not Found

#include "stdio.h"

#define MAXLEN 80

int main( )

{ int count,i,k,flag,sub;

char cc,ch,oldch,str[MAXLEN];

oldch=' ';

cc=getchar();

getchar();

while((ch=getchar())!='#'||oldch!='#'){

k=0;

while(ch!='#'&& k< MAXLEN-1){

str[k++]=ch;

ch=getchar();

}

oldch='#';

str[k]='\0';

/*---------*/

if(flag) printf("%d\n",sub);

else printf("Not Found\n");

}

}


4644743

,

,

,

:

(1)

(2)

(1)

(2)

(3)


4644743

1.

n()


4644743

ex=1+x+x2/2!+x3/3!++xn/n!

t=xi/i! t=t*x/i t=1

e=e+t

n

sacnf(%f,&x);

t=1;e=1;

for(i=1;i<=n;i++)

{t=t*x/i; e=e+t;}

en

#include<stdio.h>

void main()

{double t,e,x;int i;

scanf("%lf",&x);

scanf("%lf",&e);

t=x;i=1;e=e-1;

while(e>t)

{e=e-t;i++;t=t*x/i;}

if(e==0)

printf("%d\n",i-1);

else

printf("%d-%d\n",i-1,i);

}

eps

scanf("%f",&x);

scanf("%f",&eps);

t=1;e=0;i=1;

while(t>eps)

{e=e+t;t=t*x/i;i++;}

:


4644743

s=a+aa+aaa++aa.a

na

sn

n=0;t=0;

while(s>t)

{ s-=t;n++; t=10*t+a;}

if(s==0)

printf("%d\n",n);

else

printf("%d-%d\n",n,n+1);

t=t*10+a

s=s+t

t=0;s=0;

for(i=1;i<=n;i++)

{t=t*10+a; s=s+t;}

printf("%d\n",s);

:

Fibonacci()

s=11+22+33+44++NN

s=1+1/2+(1*2)/(2*4)+(2*3)/(3*5)+


4644743

2.

,

n (1<n<=10)n

#include <stdio.h>

int main( )

{int i, n, a[10],max;

scanf("%d", &n);

for(i=0; i<n; i++)

scanf("%lf", &a[i]);

max=a[0];

for(i=1;i<n;i++)

if(max<a[i])max=a[i];

printf("%d",max);


4644743

n (1<n<=10)n

near=a[0];def=fabs(aver-a[0]);

for(i=1;i<n;i++)

if(fabs(aver-a[i])<def)

{near=a[i];

def=fabs(aver-a[i]);

}

printf("%f\n", near);

}

#include <stdio.h>

#include <math.h>

int main( )

{int i, n;

double a[10],aver,def,near;

scanf("%d", &n);

for(i=0; i<n; i++)

scanf("%lf", &a[i]);

aver=0.0;

for(i=0;i<n;i++)

aver+=a[i];

aver=aver/n;

,

,

,


4644743

3.

1

n,,"YES,"NO"

main( )

{ int flag,n;

scanf("%d", &n);

if(n==1) flag=0;

else if(n==2) flag=1;

else {int i;

for(i=2;i<n-1;i++)

if(n%i==0) {flag=0;break;}

if(i==n) flag=1;}

if(flag) printf("YES\n");

else printf("NO\n");

}


4644743

n

#include "math.h"

main()

{int i,m,n,k=0;

scanf(%d,&n);

m=0;

for(i=2;i<=n;i++)

if(f(i)>0) m=m+i;

printf("%d\n",m);

}

}

int f(int m)

{int i,c;

if(m==2) return 1;

c=m-1;

for(i=2;i<=c;i++)

if(m%i==0)break;

if(i==c+1) return 1;

else return 0;

}


4644743

6,

10 , 10=3+7,10=5+5

#include "math.h"

main()

{int i,m,n,k=0;

scanf("%d",&m);

for(i=2;i<=m/2;i++)

if(f(i)>0)

{n=m-i;

if(f(n)>0)

printf("%d=%d+%d\n",m,i,n);

}

}

int f(int m)

{int i,c;

c=sqrt((float)m);

for(i=2;i<=c;i++)

if(m%i==0)break;

if(i==c+1) return 1;

else return 0;

}


4644743

,

100 , 97

#include <stdio.h>

main()

{int m;

scanf("%d",&m);

while(m)

if(f(m)>0)

{printf("%d\n",m);

break;

}

else m--;

}

int f(int m)

{int i,c;

if(m==2) return 1;

c=m-1;

for(i=2;i<=c;i++)

if(m%i==0)break;

if(i==c+1) return 1;

else return 0;

}


4644743

4.

1~/2

,

main()

{int x,i;

scanf("%d",&x);

for(i=1;i<=x/2;i++)

if(x%i==0)

printf("%d ",i);

printf("\n");

}


4644743

n

:

main()

{int x,i;

scanf("%d",&n);

for(m=2;m<=n;m++)

{s=0;

for(i=1;i<m/2;i++)

if(m%i==0) s=s+i;

if(s==m) printf("%d ",m);

}

printf("\n");

}


4644743

, 90,90=2*3*3*5

#include "stdio.h"

int main()

{long n,j;

scanf("%ld",&n);

printf("%ld=",n);

j=2;

while(n>j)

{

if(n%j==0){printf("%ld*",j);n=n/j;}

else j=j+1;

}

printf("%ld\n",n);

}

:


4644743

5.

n n%10 ->

n/=10 ->

n>0

.

: 12345, 5 4 3 2 1

void f(int x)

{if(x>0)

{printf("%d",x%10);

f(x/10);

}

}

void main()

{int n;

scanf("%d",&n);

f(n);

}

void main()

{int n;

scanf("%d",&n);

while(n)

{printf("%-2d",n%10);

n=n/10;

}

}


4644743

n

void main()

{int n,m=1,x;

scanf("%d",&n);

x=n;

while(x>=10)

{ x=x/10;

m=m*10;

}

while(m>0)

{printf("%-2d",n/m);

n=n%m;

m=m/10;

}

}

void f(int x)

{ if(x>=10) f(x/10);

printf("%-2d",x%10);

}

void main()

{int n;

scanf("%d",&n);

f(n);

}


4644743

,,

153=13+53+33

main()

{int n,x,y,s;

for(n=101;n<999;n++)

{x=n;s=0;

while(x)

{y=x%10;

s=s+y*y*y;

x=x/10;

}

if(n==s)printf("%d\n",n);

}}


4644743

,,

123456789 --> 45 --> 9

main()

{long x;

int n;

scanf("%ld",&x);

do{n=0;

do{n=n+x%10;

x=x/10;

}while(x!=0);

x=n;

}while(x>=10);

printf("%d\n",n);

}


4644743

m,nkm,n k? , "YES", , "NO".

: 12345 12356 3 "YES"

2345 12356 4 "NO"

for(a=1;a<=k;a++)

if(mm[--i]!=nn[--j])break;

if(a>=k+1)

printf("YES\n");

else

printf("NO\n");

}

main()

{long int m,n;

int k,mm[10],nn[10],i,j,a;

scanf("%ld%ld%d",&m,&n,&k);

i=0;

while(m)

{mm[i++]=m%10;

m=m/10; }

j=0;

while(n)

{nn[j++]=n%10;

n=n/10; }

, in digit


4644743

6.

(1):

i=0;

while(n>0)

{y=n%x;

if(y>=10)ch[i++]=y+'a'-10;

else ch[i++]=y+'0';

n=n/x;

}

ch[i]='\0';

for(j=0;j<i/2;j++)

{c=ch[j];

ch[j]=ch[i-1-j];

ch[i-1-j]=c;

}

printf("%s",ch);

n,x

,

0~9'0'~'9': y+'0'

10~15'A'~'F': y+'A'+10

'a'~'f': y+'a'+10


4644743

n7

i=0;

while(n>0)

{y=n%7;

ch[i++]=y+'0';

n=n/7;

}

ch[i]='\0';

for(j=0;j<i/2;j++)

{c=ch[j];

ch[j]=ch[i-1-j];

ch[i-1-j]=c;

}

printf("%s",ch);


4644743

xad

a0xn-1+a1xn-2+ +an-3x2 +an-2x+an-1

d=0;t=1;

n=strlen(a);

for(i=n-1;i>=0;i--)

{if(a[i]>=0&&a[i]<=9)

d=d+(a[i]-0)*t;

else if (a[i]>=A&&a[i]<=F )

d=d+(a[i]-A+10)*t;

else

d=d+(a[i]-a+10)*t;

t=t*x;

}

printf(%d,d);

( ((a0x+a1)x+ a2)x ++an-2)x+an-1

d=0;

for(i=0;a[i]!=\0;i++)

if(a[i]>=0&&a[i]<=9)

d=d*x+a[i]-0;

else if (a[i]>=A&&a[i]<=F )

d=d*x+a[i]-A+10;

else

d=d*x+a[i]-a+10;

printf(%d,d);


4644743

a123x 17960?302tab58764:123,17960,302,5876

#include <stdio.h>

main()

{char s[80];

int i,n=0;long a[10]={0},m=0;

gets(s);

for(i=0;s[i]!='\0';i++)

if(s[i]>='0'&&s[i]<='9')

m=m*10+s[i]-'0';

else

if(m>0)

{a[n++]=m;

m=0;

}

printf("\nn=%d\n",n);

for(i=0;i<n;i++)

printf("%ld ",a[i]);

printf("\n");

}


4644743

,

#include "stdio.h"

void cc(int d,char c[])

{int y,i=0,j;char ch;

while(d>0)

{y=d%16;

if(y>9)c[i++]=y-10+'a';

else c[i++]=y+'0';

d=d/16;

}

c[i]='\0';

for(j=0;j<i/2;j++)

{ch=c[j];c[j]=c[i-1-j];

c[i-1-j]=ch;}

}

int cnum(char *p)

{int d=0;

while(*p!='\0')

d=d*10+*p++-'0';

return d;

}

void main()

{int d;char a[20];

gets(a);

d=cnum(a);

cc(d,a);

printf("%s\n",a);

}


4644743

(2):

1 s(0<s<1)

s,x,n

#include <stdio.h>

void main()

{float s;int d,count;

scanf("%f",&s);

count=1;

printf("0.");

while(count<=6&&s>0)

{d=s*2;

printf("%d",d);

s=s*2-d;

count++;

}

printf("\n");

}

scanf("%f",&s);

count=1;

ch[0]='0';ch[1]='.';i=2;

while(count<=n&&s!=0)

{d=s*x;

if(d>=10)ch[i++]=d+'a'-10;

else ch[i++]=d+'0';

s=s*x-d;

count++;

}

ch[i]='\0';

printf("%s\n",ch);


4644743

7.

)

abcdcbaYESNO

#include <string.h>

f(char s[])

{ int i,j,n= strlen(s);

for(i=0,j=n-1;i<n/2;i++,j--)

if(s[i]!=s[j]) return 0;

return 1;

}

main()

{char *c;

gets(c);

if(f(c)) printf(" YES");

else printf(" NO");

}


4644743

,,YES,,NO

12321 YES

12345 NO

void main()

{long n,m=0,x;

scanf("%ld",&n);

x=n;

while(n>0)

{m=m*10+ n%10;

n=n/10;

}

if(x==m) printf(" YES");

else printf(" NO");

}

void main()

{long n;

int a[20],i=0;

scanf("%ld",&n);

while(n>0)

{a[i++]= n%10;

n=n/10;

}

for(n=0;n<i/2;n++)

if (a[n]!=a[i-n-1]) break;

if(n>=i/2) printf(" YES");

else printf(" NO");

}


4644743

8.

i==j

i<=j

i>=j

i+j==n-1


4644743

n(n<6) a . n a ,, "YES", , "NO".

:a[i][j]==a[j][i]

main()

{int a[6][6],i,j,n,flag=1;

scanf("%d",&n);

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=i+1;j<n;j++)

if(a[i][j]!=a[j][i])flag=0;

if(flag)printf("YES");

else printf("NO");

printf("\n");

}


4644743

n(n<6) a , . n a ,, "YES", , "NO".

:

a[i][j]==a[n-1-j][n-1-i]

main()

{int a[6][6],i,j,n,flag=1;

scanf("%d",&n);

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-1-i;j++)

if(a[i][j]!=a[n-1-j][n-1-i])flag=0;

if(flag)printf("YES");

else printf("NO");

printf("\n");}


4644743

n(n<6) a , 0, . n a , , "YES", , "NO".

main()

{int a[6][6],i,j,n,flag=1;

scanf("%d",&n);

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=i+1;j<n;j++)

if(a[i][j]!=0)flag=0;

if(flag)printf("YES");

else printf("NO");

printf("\n");

}

j>i


4644743

n(n<6) a , , ,...... n a , , "YES", , "NO".

main()

{int a[6][6],i,j,n,flag=1;

scanf("%d",&n);

for(i=0;i<n;i++)

for(j=0;j<n;j++)

scanf("%d",&a[i][j]);

for(i=0;i<n/2;i++)

for(j=0;j<n;j++)

if(a[i][j]!=a[n-1-i][j])flag=0;

if(flag)printf("YES");

else printf("NO");

printf("\n");

}

:

a[i][j]==a[n-1-i][j]


4644743

n(n<6) a , .() n a , , "YES", , "NO"

#include <math.h>

main()

{int a[6][6],i,j,n,s;

scanf("%d",&n);

for(i=0;i<n;i++)

for(j=0;j<n;j++)

scanf("%d",&a[i][j]);

for(i=0;i<n;i++)

{s=0;

for(j=0;j<n;j++)

if(i!=j)s=s+abs(a[i][j]);

if(s>abs(a[i][i])) break;

}

if(i>=n) printf("YES");

else printf("NO");

printf("\n");

}


4644743

a,a,a-1


4644743

9.

, , .

A Z

B Y

Y B

Z A

c='A'+'Z'-c;

, , .

0 9

1 8

8 1

9 0

c='0'+'9'-c;


4644743

10.

sn,snt, t.

main()

{char s[100],t[50];

int i,n;

gets(s);

scanf("%d",&n);

for(i=0;s[i]!='\0'&&i<n;i++)

t[i]=s[i];

t[i]='\0';

printf("%s\n",t);

}


4644743

s1s2ACSII.: 1bf

zc

15680

main()

{char s[100],t[100];

long int d=0;

int i,n;

gets(s);gets(t);

for(i=0;s[i]!='\0'&&t[i]!='\0';i++)

d+=t[i]*s[i];

printf("%ld\n",d);

}


4644743

S :

(1) S '('')'.

(2) S , .

, YES; , NO.

#include <string.h>

int check(s)

char s[];

{int l,r,i;

l=0;r=0;i=0;

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

{if(s[i]=='(')l++;

if(s[i]==')')r++;

if(r>l)break;

i++; }

return(l==r);

}

: (2+(3*6)-10) YES

(2+(3)*6)-10) NO

)(A)BC( NO

main()

{char s[100];

gets(s);

if(check(s)) printf("%s","YES");

else printf("%s","NO");

}


4644743

11.

# (80) ## (:'A','E','I','O','U')

#include "stdio.h"

int main( )

{ int count,i,k; char ch,oldch,str[80];

oldch=' ';

while((ch=getchar())!='#'||oldch!='#')

{ k=0;

while(ch!='#'&& k<79)

{str[k++]=ch; ch=getchar();}

oldch='#'; str[k]='\0'; count=0;

for(i=0;str[i]!='\0';i++)

if(str[i]>='A' && str[i]<='Z') if(str[i]!='A'&&str[i]!='E'&&str[i]!='I'&&str[i]!='O'&&str[i]!='U') count++;

printf("%d\n",count);

}

}


4644743

:

#include <stdio.h>

int main( )

{int i,count;

char str[100],c;

gets(str);

count=0; c=' ';

for(i=0;str[i]!=\0;i++)

{if(c==' '&&str[i]!=' ') count++;

c=str[i];

}

printf("count = %d\n", count);

}


4644743

12.

main()/**/

{int a[20],i,j,t,n;

scanf("%d",&n);

for(i=0;i<n;i++)

scanf("%d",&a[i]);

printf("\n");

for(i=0;i<n-1;i++)

for(j=i+1;j<n;j++)

if(a[i]>a[j])

{t=a[j];a[j]=a[i];a[i]=t;}

for(i=0;i<n;i++)

printf("%d ",a[i]);

printf("\n");

}

n,

main()/**/

{int a[20],i,j,t,n;

scanf("%d",&n);

for(i=0;i<n;i++) scanf("%d",&a[i]);

printf("\n");

for(i=0;i<n-1;i++)

for(j=0;j<n-1-i;j++)

if(a[j]>a[j+1])

{t=a[j];a[j]=a[j+1];a[j+1]=t;}

for(i=0;i<n;i++)

printf("%d ",a[i]);

printf("\n");

}


4644743

n(n>20).:,22,.

main( )

{ int i,n;

double a[20],aver;

scanf("%d", &n);

for(i=0; i<n; i++)

scanf("%lf", &a[i]);

sort(n,a);

aver=0;

for(i=2;i<n-2;i++)

aver+=a[i];

aver/=n-4;

printf("aver=%.2f\n", aver);

}

void sort(int n,double a[])

{int i,j,index;

double t;

for(i=0;i<n-1;i++)

{index=i;

for(j=i+1;j<n;j++)

if(a[j]<a[index]) index=j;

t=a[i];

a[i]=a[index];

a[index]=t;

}

}


4644743

main()

{int a[20],i,t,n;

scanf("%d",&n);

for(i=0;i<n;i++)

scanf("%d",&a[i]);

printf("\n");

t=a[0];

for(i=1;i<n-1;i++)

if(t>a[i])

break;

else

t=a[i];

printf("%d\n",i);

}


4644743

main()

{int a[20],m,n,i;

scanf("%d",&n);

for(i=0;i<n;i++) scanf("%d",&a[i]);

scanf("%d",&m);

a[n]=m;

for(i=n-1;i>=0;i--)

if(a[i+1]<a[i])

{m=a[i+1]; a[i+1]=a[i]; a[i]=m;

}

for(i=0;i<=n;i++)

printf("%d ",a[i]);

printf("\n");

}


4644743

13.

naxax"Not found"

#include <stdio.h>

int main(void)

{ int i, index, n, x,a[10];

scanf("%d", &n);

for(i=0;i<n;i++)

scanf("%d", &a[i]);

scanf("%d", &x);

index=find(a,n,x);

if(index!=-1)

printf("index = %d\n",index);

else

printf("Not found\n");

}

int find(int a[], int n, int x)

{int i;

for(i=0;i<n;i++)

if(x==a[i]) return i;

return -1;

}


4644743

() ()

a[9]={1,2,3,6,8,9,10,12,14}

0 1 2 3 4 5 6 7 8

x=2

a0~8 (0+8)/2=4 a[4]=8

a 0~3 5~8 0~3

a0~3 (0+3)/2=1 a[1]=2=x


4644743

a

a[0]~a[N-1]:

x:

top:

bot:

mid:

x

top=0, mid=0

bot=N-1

0

x>a[bot]||x<a[top]

0

top<=bot

1

1

mid=(top+bot)/2

0

x==a[mid]

1

0

x<a[mid]

break

1

bot=mid-1

top=mid+1

0

x==a[mid]

1

mid,x


4644743

#define N 10

#include "stdio.h"

void main()

{int a[N],top=0,bot=N-1,mid=0,x,i;

for(i=0;i<N;i++) scanf("%d",&a[i]);

scanf("%d",&x);

if(x>=a[0]&&x<=a[N-1])

while(top<=bot)

{mid=(top+bot)/2;

if(x==a[mid]) break;

else if(x<a[mid]) bot=mid-1;

else top=mid+1;

}

if(x==a[mid]) printf("a[%d]=%d\n", mid,a[mid]);

else printf("no number");

}


4644743

str c str c

#include<stdio.h>

void main()

{char c,str[80];

int i,j=0;

gets(str);

scanf("%c", &c);

for(i=0;str[i]!=0;i++)

if(str[i]!=c) {str[j]=str[i];j++;}

str[j]='\0';

puts(str);

}


4644743

, YES; , NO.

#include <string.h>

main()

{char s[100],c[20];

int i,j,flag;

gets(s);gets(c);

for(i=0;s[i]!='\0';i++)

{flag=1;

for(j=0;c[j]!='\0';j++)

if(s[i+j]!=c[j]){flag=0;break;}

if(flag) break;

}

if(flag) printf("YES\n");

else printf("NO\n");

}

abcdefghy

efg

,


4644743

14.

,,,,m?

#include <stdio.h>

void main()

{int i, n=1,m;

scanf("%d",&m);

for(i=m-1;i>=1;i--)

n=(n+1)*2;

printf("%d",n);

}


4644743

n,n?n-12n-1?n-22,, 3?22 2?12 1,105

int age(int n)

{int c;

if(n==1) c=10;

else c=age(n-1)+2;

return(c);}

void main()

{int n;

scanf("%d",&n);

printf("%d\n ",age(n));

}

#include <stdio.h>

void main()

{int i,n,m=10;

scanf("%d",&n);

for(i=1;i<n;i++)

m=m+2;

printf("%d\n ",m);

}

:


4644743

15.

#include "stdio.h"

void main( )

{ int i,j,n;char c;

scanf("%d",&n);

for(i=1;i<=n;i++)

{c='1'-1;

for(j=1;j<=2*n-1;j++)

if(j<=n-i) printf(" ");

else if(j<=n)

{c=c+1; printf("%c",c);}

else if(j<n+i)

{c=c-1; printf("%c",c);}

printf("\n");

}

}

1

121

12321

1234321

123454321

A

ABA

ABCBA

ABCDCBA


4644743

a,ba>=bnn, n

#include "stdio.h"

long pown(long b,int n)/*bn*/

{int i;

long g=1;

if (n==0) return 1;

for(i=1;i<=n;i++)

g=g*b;

return g;

}

void main( )

{

int n;

long a,b;

scanf("%ld%ld",&a,&b);

n=0;

while(a>pown(b,n))

n++;

printf("%d\n",--n);

}


4644743

(::)

,6465


4644743

1

a

k=1;k<n;k++

i=0;i<n;i++

0

a[row][col]>a[k][col]

col=0

1

j=1;j<n;j++

row=k

0

a[i][col]<a[i][j])

k

1

0

row==i

col=j

1

i,col

j

row=0

i

1

NO

(, )

1.i,ij=>col

2.colk=>row

3.i==row,rowcol

void main()

{int i,j,k,row,col,flag=0,n;

int a[6][6];

scanf("%d",&n);

for(i=0;i<n;i++)

for(j=0;j<n;j++)

scanf("%d",&a[i][j]);

for(i=0;i<n;i++)

{col=0;

for(j=1;j<n;j++)

if(a[i][col]<a[i][j])col=j;

row=0;

for(k=1;k<n;k++)

if(a[i][col]>a[k][col])row=k;

if(row==i) {flag=1;break;}

}

if(flag)

printf("i=%d,j=%d",row,col);

else printf("NO");

}


4644743

aij

1.ijaij

2.imax

3.jmin

4. max==min==aij

ij

#include<stdio.h>

void main()

{int n,i,j,p,max,min,a[6][6];

scanf("%d",&n);

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++)

{max=a[i][0];

for(p=1;p<n;p++)

if(max<a[i][p]) max=a[i][p];

min=a[0][j];

for(p=1;p<n;p++)

if(min>a[p][j]) min=a[p][j];

if(max==min&&max==a[i][j])

{printf("%d %d\n",i,j); return;}

}

printf("no\n");}


  • Login