C + + fifth time job

Source: Internet
Author: User

One, array selection from the keyboard input 10 number in the array A, the number of non-repeating in the array in array b #include<iostream>  using namespace std;  int main ()  {      const int n=10;      int a[n],b[n],i,j,k=0;      for (i=0;i<n;i++)      cin>>a[i];      for (i=0;i<n;i++)      {for          (j=0;j<n+1;j++)          {              if (i==j) continue;              if (A[i]==a[j]) break;              if (j==10)              {                 b[k]=a[i];                 k++      ;      }}} cout<< "non-repeating array:";      for (i=0;i<k;i++)      cout<<b[i]<< ",";  return 0;  }  

Second, sum input 10 numbers from the keyboard into array a, and #include<iostream> using namespace std for positive and negative numbers in a array  ;  int main ()  {      const int n=10;      int a[n],i,sum1=0,sum2=0;      cout<< "Input 10 number:";      for (i=0;i<n;i++)      {            cin>>a[i];          if (a[i]>0)          sum1=sum1+a[i];          else if (a[i]<0)          sum2=sum2+a[i];      }      cout<< "positive and;" <<sum1<< "\ n";      cout<< "negative and;" <<sum2;      return 0;  }  

String 0 (large/lowercase) number of letters, number of digits and number of other characters </span> #include <iostream>  #include <cstdio>  using namespace Std;  int main ()  {      char str[50];      int i=0,n=0,j=0,k=0,l=0;      cout<< "input string:";      Gets (str);      while (str[i]!= ')      {          if (str[i]>= ' 0 ' &&str[i]<= ' 9 ')          n++;          else if (str[i]>= ' a ' &&str[i]<= ' Z ')          j + +;          else if (str[i]>= ' A ' &&str[i]<= ' Z ')          k++;          else l++;          i++;      }      cout<< "Number of Numbers:" <<n<<;      cout<< "Number of lowercase letters:" <<j<<;      cout<< "Number of capital letters:" <<k<<;      cout<< "Number of other characters:" <<l;      return 0;  }  

C + + fifth time job

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.