码迷,mamicode.com
首页 > 其他好文 > 详细

VS2010暂停编译界面

时间:2017-08-20 00:52:49      阅读:351      评论:0      收藏:0      [点我收藏+]

标签:span   core   index   bit   小伙伴   get   etc   .com   http   

注:文章主要知识点来源于https://www.felix021.com/blog/read.php?981

本人主要是按照自己的理解略微整理,感谢原博主Felix201的分享!


正文如下


刚上手VS2010的小伙伴们,可能会苦恼编译界面一闪而过,确实,这个在VC2006压根是不存在的,具体解决办法有三,如下:

  1. 在程序末加getchar();
  2. 添加头文件#include "stdlib.h" ,并在程序末添加system("pause");;
  3. 在需要暂停的地方写入死循环while(1); ,按下CTRL+C可以退出。

注:在涉及到输入函数scanf();时,方法1失效(可使用N+1个getchar();其中N为输入数据的个数);建议使用方法2;勿使用方法3。


具体代码表现如下:

/***************************************************
//使用循环进行数组处理
***************************************************/

#include "stdafx.h"
#include "stdio.h"
#include "stdlib.h"

#define SIZE 2
#define PAR 72

int main(void)
{
    int index;
    int score[SIZE];
    int sum=0;
    float average;

    printf("Enter %d golf scores:\n",SIZE);
    for(index=0;index<SIZE;index++)
    {
        scanf("%d",&score[index]);
    }
    printf("The scores input in are as follows:\n");
    //Good Habits:使用程序输出或“回显”刚刚输入的值,这样有助于确保程序处理了您所期望的数据
    for(index=0;index<SIZE;index++)
    {
        printf("%5d",score[index]);
    }
    printf("\n");

    for(index=0;index<SIZE;index++)
    {
        sum+=score[index];
    }
    average=(float)sum/SIZE;

    printf("Sum of scores = %d,average = %0.2f\n",sum,average);

    //getchar();
    //getchar();
    //getchar();
    system("pause");
    return 0;
}        

 

VS2010暂停编译界面

标签:span   core   index   bit   小伙伴   get   etc   .com   http   

原文地址:http://www.cnblogs.com/haoger/p/7398232.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!