注册 登录
编程论坛 C++教室

程序编写学习!

wtoo2008 发布于 2010-12-12 22:28, 1481 次点击
小弟刚学习完《C.Primer.Plus(第五版)中文版》基础。现学习写一些简单程序和大家分享、分享。
“题目是编写一个程序显示出下列结果:
* * * * * * * * * * * * * *
    Very  Good!      
* * * * * * * * * * * * * *

程序如下:

#include <stdio.h>   
int main(void)
{
 printf("* * * * * * * * * * * * * *\n");
 printf("      Very  Good!          \n");
 printf("* * * * * * * * * * * * * *\n");
 return 0;
}

该程序在windowssp2、 VC++6.0中能正常运行。
请大家指教指教,看看有那个高手能用其它C语句写出该程序,大家互相学习这才能有提高、有兴趣地学习好VC++。
谢谢大家!

13 回复
#2
yy22222010-12-12 23:31
#include <iostream>
using namespace std;   
void main()
{
cout<<"* * * * * * * * * * * * * *"<<endl;
cout<<"      Very  Good!          "<<endl;
cout<<"* * * * * * * * * * * * * *"<<endl;
}
一只在看C++  就用 了 。。
#3
laoyang1032010-12-13 09:37
哈哈   楼主写得不错
#4
tangyz9222010-12-13 11:31
#include <iostream>
using namespace std;   
void main()

   int i,j;
   for(i=0;i<14;i++)
     cout<<"*"<<endl;
cout<<"      Very  Good!          "<<endl;
for(j=0;j<14;j++)
cout<<"*"<<endl;
return 0;
}
#5
lonlongg2010-12-13 11:55
我第一次发帖,

崩溃
#6
洪溪2010-12-13 13:08
回复 4楼 tangyz922
可爱
#7
jiasenlin2010-12-13 13:30
未来的IT人才。 顶了
#8
小K鸟2010-12-13 17:17
这个问题有待深究,,,
#9
wtoo20082010-12-13 20:12
请问下,C++与VC++有什么不同,为什么编写出来的语句不一样的。
#10
八画小子2010-12-13 20:20
回复 9楼 wtoo2008
C++和VC++不能作比较。C++是一种面向对象编程语言,VC++是一种针对C++的IDE
#11
dingxiaowu2010-12-14 12:51
呵呵
#12
missiyou2010-12-14 13:43
string Msg(int length, char *cstr)
{
    string str(length, '*');
    int size = int(str.length() / 3);
    str.replace(size, 1, 1,  '\n');
    str.replace(size*2,  1, 1, '\n');
    string str1(cstr);
    str.replace(size + 1, size -1, size -1, ' ');
    int  repalce_begin =int( (str.length() - str1.length())/2);
    str.replace(repalce_begin, str1.length(), str1.c_str(), 0, str1.length() ); // 晕一直在替换!!!!!!!
    return str;
}

string str = Msg(300, "Very Good");
cout << str.c_str() << endl;
#13
wtoo20082010-12-14 20:58
多谢大家对编程热爱,有C、VC++还有“Missiyou"网友的程序是用C#写的吗?真是太好了,同一个问题能用不同C写出来,这样学习才有兴趣啊。谢谢大家回帖。
#14
khin2011-01-05 12:39
好强悍的....
1