'commit'
This commit is contained in:
49
C++课程/第十六课循环结构程序设计实例2/p175.cpp
Normal file
49
C++课程/第十六课循环结构程序设计实例2/p175.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
|
||||
void show(int n,int i,int j) {
|
||||
int a,b,c;
|
||||
b=i;
|
||||
c=j;
|
||||
for(a=1; a<=n; a++) { //<2F><><EFBFBD><EFBFBD>ͬһ<CDAC><D2BB><EFBFBD>ϵ<EFBFBD>λ<EFBFBD><CEBB>
|
||||
printf("(%d,%d)",i,a);
|
||||
}
|
||||
printf("\n");
|
||||
for(a=1; a<=n; a++) { //<2F><><EFBFBD><EFBFBD>ͬһ<CDAC><D2BB><EFBFBD>ϵ<EFBFBD>λ<EFBFBD><CEBB>
|
||||
printf("(%d,%d)",a,j);
|
||||
}
|
||||
printf("\n");
|
||||
while(i>0&&j>0) { //<2F><><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>¶Խ<C2B6><D4BD><EFBFBD><EFBFBD>ϵĸ<CFB5><C4B8>ӵ<EFBFBD>λ<EFBFBD><CEBB>
|
||||
i--;
|
||||
j--;
|
||||
}
|
||||
i++;
|
||||
j++;
|
||||
while(i<=n&&j<=n) {
|
||||
printf("(%d,%d)",i,j);
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
printf("\n");
|
||||
i=b;
|
||||
j=c;
|
||||
while(i<=n&&j>0) { //<2F><><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD>϶Խ<CFB6><D4BD><EFBFBD><EFBFBD>ϵĸ<CFB5><C4B8>ӵ<EFBFBD>λ<EFBFBD><CEBB>
|
||||
i++;
|
||||
j--;
|
||||
}
|
||||
i--;
|
||||
j++;
|
||||
while(i<=n&&j<=n&&i>0&&j>0) {
|
||||
printf("(%d,%d)",i,j);
|
||||
i--;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
int main() {
|
||||
int n,i,j;
|
||||
scanf("%d %d %d",&n,&i,&j);
|
||||
if(1<=i&&i<=n&&1<=j&&j<=n)
|
||||
show(n,i,j);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user