matlab里如何实现跳行的功能,就想是C语言里面的go to next然后在相应位置输入next就行了。

Python021

matlab里如何实现跳行的功能,就想是C语言里面的go to next然后在相应位置输入next就行了。,第1张

if conditionA

func_LabelA()

end

1. goto 完之后还要回来的:把在c里面原来到goto之后要做的事情写成一个函数

2. 其他的情况,应该都可以用break/continue/return 出来

/*他还不完善*/

#include <stdio.h>

#include <conio.h>                                             //管理 getch ()

#include <stdlib.h>                                            //管理 exit  ()

void menu ()                                                  //菜单函数声明

void login ()                                                 //密码函数

int login1 ()                                                 //密码函数的返回

void zhukong ()                                               //主控函数

double add (double x,double y)                                //各各算法

double divide (double x,double y)

double multipliaction (double x,double y)

double subtract (double x,double y)

int qiuyu (int x,int y)

double liejia (int x, double y)

double liecheng (int x, double y)

double duojia (int x)

int jiechengliejia (int x)

int main()                                                            //主函数

{

    login ()                                                         //调用密码函数

    zhukong ()                                                       //调用主控函数

    return 0                                                         //返回值为零

}

void menu ()

{

  printf("===========================================\n")            //菜单语句

  printf("|-------计---算---器---主---菜---单-------|\n")

  printf("===========================================\n")

  printf("|——————————+——————————|\n")

  printf("|     Ⅰ--加法       |       Ⅱ--减法     |\n")

  printf("|——————————|——————————|\n")

  printf("|     Ⅲ--乘法       |       Ⅳ--除法     |\n")

  printf("|——————————|——————————|\n")

  printf("|     Ⅴ--求余       |       Ⅵ--阶加     |\n")

  printf("|——————————|——————————|\n")

  printf("|     Ⅶ--阶乘       |       Ⅷ--多加     |\n")

  printf("|——————————+——————————|\n")

  printf("|     Ⅸ--阶乘累加   |    反正就是计算器  |\n")

  printf("|——————————+——————————|\n")

  printf("===========================================\n")

  printf("|                ¤--退出             -kk |\n")

  printf("===========================================\n")

  printf ("\n")

}

void login ()

{

    int passward

    passward=login1 ()

    if (passward==1)

    {

    printf ("密码正确! 欢迎使用!\n")

    printf ("按任意键继续……\n\n\n\n\n\n\n")

    getch ()

    zhukong ()

    }

    else

    exit (0)

}

void zhukong ()

{

      char a                                                             //定义字符串

      double b,c,d

      while(1)

      {

ceshi1:

      menu ()

      printf ("请输入您的选择:\n")

      scanf("%c",&a)

      if (a=='0')

{

      printf("\n\n\n\n\n\n\n\n\n\n\n\n\n感谢您的使用~\n\n\n\n\n\n\n\n")

      exit(0)

}

      else if (a!='1'&&a!='2'&&a!='3'&&a!='4'&&a!='5'&&a!='6'&&a!='7'&&a!='8'&&a!='9')

       {

        printf ("您的输入有误,请重新输入!\n\a\a")

        fflush(stdin)                                                    //清除缓存

        getch ()

        system ("cls")                                                   //清除屏幕

        goto ceshi1                                                      //go to 的应用点

       }

   else if(a!='8')                                                        //关于多加的特殊处理

{

      printf("请输入第一个数 用回车确定\n")

      scanf("%lf",&b)

      printf("请输入第二个数 用回车开始计算\n")

      scanf("%lf",&c)

      switch (a)                                                          //开始选择

 {

 case'1':

 d=add (b,c)

 break

 case'2':

 d=divide (b,c)break

 case'3':

 d=multipliaction (b,c)break

 case'4':

 d=subtract (b,c)break

 case'5':

 d=qiuyu (b,c)break

 case'6':

 d=liejia (b,c)break

 case'7':

 d=liecheng (b,c)break

 case'8':

 d= duojia (b)break

 case'9':

 d=jiechengliejia (b)break

 default :

 {

 printf ("您的输入有误,请重新输入!\n\a\a")

        fflush(stdin)                                                     //清除缓存

        getch ()

        system ("cls")                                                    //清除屏幕

        goto ceshi1

         break

 }

 goto ceshi1                                                              //go to 的开始点

 break

 }

}

else

{

   printf ("请输入要相加的次数:\n")

   scanf ("%lf",&b)

   d= duojia (b)

}

   printf ("得到的答案是:%5.2lf\n\n\n\n\n\n\n",d)

   fflush(stdin)

   printf ("按任意键继续……\n")

   getch()

   system ("cls")

}

}

int login1 ()                                                             // 各种返回值 函数

{

  char a[20]

  int i

  printf("▁▁▁▁▁▁▁▁▁\n")

  printf("▏您共有三次机会▕\n")

  printf("▔▔▔▔▔▔▔▔▔\n")

  printf("密码为→:abc123\n")

  printf("▔▔▔▔▔▔▔▔▔\n")

  i=0

while (i<3)

{

    printf("▁▁▁▁▁▁▁▁▁\n")

     printf("请输入密码:")

     scanf("%s",&a)

     printf("▔▔▔▔▔▔▔▔▔\n")

     if (0 == strcmp(a,"abc123") )

     return 1

     else

     printf("密码错误!请重新输入№№\a\n")

     i++

}

   printf ("№№№三次错误!系统退出!№№№\a\a\a\n")

   exit (0)

}

double add (double x,double y)

{

      double d

      d=x+y

      return d

}

double divide (double x,double y)

{

      double d

      d=x-y

      return d

}

double multipliaction (double x,double y)

{

      double d

      d=x*y

      return d

}

double subtract (double x,double y)

{

    double d

        if (y==0)

         {

           printf("分母不能为“0”!\n")

           printf ("按任意键继续……")

           getch ()

           zhukong ()

         }

    else

           d=x/y

    return d

}

int qiuyu (int x,int y)

{

     int d

     d=x%y

     return d

}

double liejia (int x, double y)

{

     double d,z

     z=0

     d=0

while (z<y)

{

     d+=x

     z++

}

     return d

}

double liecheng (int x, double y)

{

     double d,z

     z=0

     d=1

     while (z<y)

    {

     d=d*x

     z++

    }

     return d

}

double duojia (int x)

{

    int i,d,t

    double z

    d=0

    t=0

      for (i=0i<xi++)

      {

        printf ("请输入%d个数!\n",t=t+1)

        scanf ("%lf",&z)

          d+=z

      }

    return d

}

int jiechengliejia(int x)

{

    int a,e,q,s,t

    e=0

    q=1

    t=0

    a=1

    while (t<x)

    {t++

   while (a<=t)

   {

       q=a*q

       a++

   }

   e=q+e

    }

return e

}

/*

不完善点

1、 密码输入正确后选择会提示错误

2、 有很多用的if来判断对错

3、 在所有的算法中 多加是另外执行的

4、 加减乘除只能单独运算 不能和在一起

*/

要是只要接收回车就结束循环的话,就直接用while(c!='\n')就可以啦

我是这样写的,请楼主参考:

#include <stdio.h>

main()

{ char c;

int zm=0;

while(c=getchar()!='\n')

zm++;

printf("单词个数为%d”,zm);}