1.引入標頭檔案#include "stdafx.h"和#include "stdio.h"。
2.寫出主函式void main(){},在函式體內寫出如下程式碼:
int number = 0;
while(true)
{
printf("請輸入數字:\n");
scanf ("%d",&number);
if (number == 1)
return;
}
程式清單:
// 停止迴圈.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stdio.h"
void main()
1.引入標頭檔案#include "stdafx.h"和#include "stdio.h"。
2.寫出主函式void main(){},在函式體內寫出如下程式碼:
int number = 0;
while(true)
{
printf("請輸入數字:\n");
scanf ("%d",&number);
if (number == 1)
{
return;
}
}
程式清單:
// 停止迴圈.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "stdio.h"
void main()
{
int number = 0;
while(true)
{
printf("請輸入數字:\n");
scanf ("%d",&number);
if (number == 1)
{
return;
}
}
}