下面的程序是C++教材里面的,然后我在DEV-C++里面运行,进入DOS界面闪一下就没了,看不到输出,这是为什么
#include<iostream.h>intmain(){intmyAge=39;//initializetwointegersintyourAge=39;cout<<...
#include <iostream.h>
int main()
{
int myAge = 39; // initialize two integers
int yourAge = 39;
cout << "I am: " << myAge << " years old.\n";
cout << "You are: " << yourAge << " years old\n";
myAge++; // postfix increment
++yourAge; // prefix increment
cout << "One year passes...\n";
cout << "I am: " << myAge << " years old.\n";
cout << "You are: " << yourAge << " years old\n";
cout << "Another year passes\n";
cout << "I am: " << myAge++ << " years old.\n";
cout << "Let's print it again.\n";
cout << "I am: " << myAge << " years old.\n";
cout << "You are: " << yourAge << " years old\n";
return 0;
} 展开
int main()
{
int myAge = 39; // initialize two integers
int yourAge = 39;
cout << "I am: " << myAge << " years old.\n";
cout << "You are: " << yourAge << " years old\n";
myAge++; // postfix increment
++yourAge; // prefix increment
cout << "One year passes...\n";
cout << "I am: " << myAge << " years old.\n";
cout << "You are: " << yourAge << " years old\n";
cout << "Another year passes\n";
cout << "I am: " << myAge++ << " years old.\n";
cout << "Let's print it again.\n";
cout << "I am: " << myAge << " years old.\n";
cout << "You are: " << yourAge << " years old\n";
return 0;
} 展开
4个回答
展开全部
加getch();
作用是接收一个字符,这样当程序结束前,需要你输入一个字符才能继续。
注意要加到return前边
如下:
cout << "I am: " << myAge << " years old.\n";
cout << "You are: " << yourAge << " years old\n";
getch();
return 0;
}
C++编译器不推荐DEV,我推荐CODEBLOCKS,学习或者做项目都很好用。
作用是接收一个字符,这样当程序结束前,需要你输入一个字符才能继续。
注意要加到return前边
如下:
cout << "I am: " << myAge << " years old.\n";
cout << "You are: " << yourAge << " years old\n";
getch();
return 0;
}
C++编译器不推荐DEV,我推荐CODEBLOCKS,学习或者做项目都很好用。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
它运行完了就关闭了
有个语句 好像是 System("pause');
你加在 return 前面 ,让它 暂停一下
有个语句 好像是 System("pause');
你加在 return 前面 ,让它 暂停一下
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你在return 0;前面加上一句system("pause");就OK了!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询