Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 输入正确的号码后,如何使该程序停止运行?_Objective C - Fatal编程技术网

Objective c 输入正确的号码后,如何使该程序停止运行?

Objective c 输入正确的号码后,如何使该程序停止运行?,objective-c,Objective C,输入正确的号码后,如何使该程序停止运行?“目标-C int number; NSLog(@"Enter number greater then 1 and less than 50 : "); scant ("%i", &number); int exponent; exponent = number; do {

输入正确的号码后,如何使该程序停止运行?“目标-C

int number;        
        NSLog(@"Enter number greater then 1 and less than 50 : ");
        scant ("%i", &number);   
        int exponent;            
        exponent = number;       
        do
        {
            if ((exponent > 0)&&(exponent < 50))  
        {
                for(int i = 1; i <= exponent;i++)   //Using for 
        {                    
                NSLog(@"N      %i \n",  (int)((pow(i, 1) * 100) / 100.0));
                NSLog(@"N^2 %4d \n", (int)((pow(i, 2) * 100) / 100.0));
                NSLog(@"N^3 %4d \n", (int)((pow(i, 3) * 100) / 100.0));
                NSLog(@"N^4 %4d \n", (int)((pow(i, 4) * 100) / 100.0));
                                NSLog(@"N^5 %4d \n", (int)((pow(i, 5) * 100) / 100.0));
                NSLog(@"  \n");                 
                }
            }
            else
            {
                NSLog(@"Number you entered is out of range");
                exponent = number;
            }
        }while (number !=0);        
    }
    return 0;
整数;
NSLog(@“输入大于1小于50的数字:”);
不足(“%i”和“编号”);
整数指数;
指数=数字;
做
{
如果((指数>0)和(&(指数<50))
{

对于(int i=1;i在
if
块内将
number
设置为
0

if ((exponent > 0)&&(exponent < 50)) {
    number = 0; // this will make the "while" check fail and end the loop

    for ...
} else {
}
if((指数>0)和&(指数<50)){
number=0;//这将使“while”检查失败并结束循环
对于
}否则{
}

要停止程序,请使用exit(0)。它将退出主线程