- UID
- 46356
注册时间2008-2-20
阅读权限30
最后登录1970-1-1
龙战于野

TA的每日心情 | 开心 2022-4-1 09:59 |
---|
签到天数: 76 天 [LV.6]常住居民II
|
发表于 2009-5-15 23:09:15
|
显示全部楼层
以下Code在VC6.0SP1下编译通过!!!
- #include <iostream.h>
- //#include <math.h>
- #include <stdio.h>
- int main()
- {
- int i, j, k, f ,n;
- start:
- cout << "请输入棱形数字,须为奇数:";
- cin >> n;
- if (!(n % 2))
- {
- cout << "输入数字有误,请重新输入!" << endl;
- goto start;
- }
- f = n / 2;
- for (i = 0; i < n; i++)
- {
- for (j = 0; j <= n; j++)
- {
- k = f - i < 0 ? i - f : f - i;
- if (j == k || j == n - 1 - k)
- {
- //cout << "*";
- printf("*");
- }
- else if (j == n)
- {
- //cout << endl;
- printf("\n");
- }
- else
- //cout << " " << endl;
- printf(" ");
- }
- }
- return 0;
- }
复制代码 |
|