poj 3091 Triangular N

poj 3091 Triangular N,第1张

poj 3091 Triangular N
#include <stdio.h>#include <string.h>#include <math.h>int main(){    int n, c, i;    scanf("%d",&c);    for (i=1; i<=c; i++)    {scanf("%d",&n);int j, m;j = (n*2+1)/3;printf("%d %d %dn", i, n, j);if (n==3){printf("[1,1] [3,2]n");continue;}else if (n==2){printf("[1,1]n");continue;}int p=0;for (j=n+1-j, m=1; m<=j&&j<=n; j++, m=m+2){if (m>1&&p%8!=0)printf(" ");printf("[%d,%d]", j, m);p++;if (p%8==0)printf("n");}for (m=2; j<=n; j++, m=m+2){ if (p%8!=0)printf(" "); printf("[%d,%d]", j, m);p++;if (p%8==0)printf("n");}printf("n");}    return 0;}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4906235.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-12
下一篇 2022-11-12

发表评论

登录后才能评论

评论列表(0条)

保存