June 26, 2019: a calendar issue, sum integer, an odd sum

Subject description:

Assuming that 2012 January 1 is a Sunday, a request n days of the week

Enter a description:

A plurality of groups of inputs each input positive integer n (1 <= n <= 2000)

Output Description:

For each input and output an integer i (1 <= i <= 7), n represents the days of the week

Sample input:

1

2

Sample output:

1

2

#include<iostream>

using namespace std;

int main()
{
int n;
while(cin>>n)
cout<<(n-1)%7+1<<endl;
return 0;
}

02 integer sum

Subject description:

And obtaining n integers.

Enter a description:

Conduct a first positive integer n (1 <n <1000), next n lines each an integer.

Output Description:

A positive integer, for the given number and all.

Sample input:

4

1

2

3

4

Sample output: 10

#include<iostream>
using namespace std;
int main()
{
int i,n;
while(cin>>n){
int sum=0;
for(i=0;i<n;i++)
{
int a;
cin>>a;
sum+=a;
}
cout<<sum<<endl;
}
return 0;
}

03 odd sums

Subject description:

10 given positive integer, each positive integer less than 10,000, wherein the odd outputs are summed and

Enter a description:

Input line, comprising 10 positive integers

Output Description:

Output line, the input is a positive integer and all odd

Sample input:

1 2 3 4 5 6 7 8 9 10

Sample output:

25

 

#include <iostream>
using namespace std;
int main()
{
int i,n;
while(cin>>n)
{
int sum;
if(n%2==1) sum=n;
else sum=0;
for(i=0;i<9;i++)
{
int a;
cin>>a;
if(a%2==1)
sum+=a;
}
cout<<sum<<endl;
}
return 0;
}

 

 

Guess you like

Origin www.cnblogs.com/laxymomo/p/11094117.html
sum