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

[求助]如何做这个程序?

dengtc 发布于 2007-05-14 11:53, 771 次点击

编写一个C++程序,它使用3个用户定义的函数(包括main()),并生成下面的输出:
Three blind mice
Three blind mice
See how they run
See how they run
其中一个函数要调用两次,该函数生成前两行;另一个函数也被调用两次,并生成其余的输出.

请各位大哥帮帮忙!!

[此贴子已经被作者于2007-5-14 14:01:22编辑过]

13 回复
#2
kisscjy2007-05-14 16:41

很简单啊,楼主为什么不自己想想啊??

#3
kisscjy2007-05-14 16:45

#include<iostream>
using namespace std;

void print1()
{
cout<<"Three blind mice"<<endl;
}

void print2()
{
cout<<"See how they run"<<endl;
}

void main()
{
for(int i=0;i<2;i++)
{
print1();
}

for(i=0;i<2;i++)
{
print2();
}

}

应该是这样了~~~

#4
dengtc2007-05-15 11:05
#include <iostream>
using namespace std;
void a(int);
void b(int);
int main()
{
a(1);
a(2);
b(1);
b(2);
cin.get();
cin.get();
return 0;
}
void a(int n)
{
cout <<"Three blind mice\n";
}
void b(int c)
{
cout <<"See how they run\n";
}
这样行吗?
#5
dengtc2007-05-15 11:06
#include <iostream>
using namespace std;
void a(int);
void b(int);
int main()
{
a(1);
a(2);
b(1);
b(2);
cin.get();
cin.get();
return 0;
}
void a(int n)
{
cout <<"Three blind mice\n";
}
void b(int c)
{
cout <<"See how they run\n";
}
这样行吗?
#6
aipb20072007-05-15 11:43
加个参数没必要啊!

这样不如直接不加参数a();a();b();b();
#7
kisscjy2007-05-15 12:16

cin.get();
cin.get();


这个函数也没必要加上去啊~~~

#8
raulxxyuer2007-05-15 12:25
#9
dengtc2007-05-16 14:49
可是不加
cin.get();
cin.get();
调试后其结果就一闪而过了啊?
#10
kisscjy2007-05-16 14:57

不知道你用什么编译器~~
我用的是VC6.0,
不会出现你说的问题~~~

#11
dengtc2007-05-16 15:06
我用的是VC++2005
#12
独孤浪子2007-05-16 15:23
只执行不调试就行(ctrl+F5)
#13
kisscjy2007-05-16 15:36
你可以在程序后加上:

system("pause")
就不会一闪而过了
#14
dengtc2007-05-16 18:06
谢谢独孤浪子和kisscjy!!
你们两个说的我都试过了!都行!!
1