C++ Reverse Array

后端 未结 4 755
北恋
北恋 2020-12-01 20:22

In C++, I need to:

  • Read in a string from user input and place it into a char array [done]
  • Then pass that array to a function [done]
  • The funct
4条回答
  •  一向
    一向 (楼主)
    2020-12-01 20:41

    //this program helps you to find maximum and minimum number in an array

    #include
    #include
    int main()
    {int max;
    
        int a[5]={12,1,0,4,5};
     int min=a[0];
        int i=1;
        max=a[0];
    
        while(i<=4)
        {
                  if (max < a[i])
                  max=a[i];
                  if (min > a[i])
                  min=a[i];
                  i++;
    
        }
                  cout << min <<"\n";
                  cout << max;
                  getch();
                  return 0;
    }              
    

提交回复
热议问题