Home > Back-end >  C programming: write a program that, given an integer from 1 to all integer Numbers together (includ
C programming: write a program that, given an integer from 1 to all integer Numbers together (includ

Time:06-06

Requirements: don't put the number of intermediate can be divided exactly by 5 or 7 (1) and n included) included in the total number,
Input, your program should read the lines from standard input, each line contains a positive integer,
Output: the input of each line, will be of Numbers from 1 to n, and output to standard output, ignore those Numbers can be divided exactly by 5, and 7, print out each result in the new row,


CodePudding user response:

Then your code?

CodePudding user response:

Write programs as required to
 
/* -
* Copyright (C), 1999-2019, mymtom.
* _
* ____ _ _ ____ _ | | _ _____ _____
* | \ | | | | (_ _) _ \ | \
* | | | | | _ | | | | | | | | | _ | | | | |
* | _ | _ _ - | | \ | _ | _ _ - | | \ () ___/| _ | _ | _ |
* (____/
*
* https://bbs.csdn.net/topics/395126735
*/

/* *
* @ file sum. CPP
* @ brief,
*/

#include
using namespace std;

#include

Static int
The sum (int last)
{
Int total;

Total=0;
For (int number=1; Number & lt;=last; Number++) {
If (number % 5==0 | | number % 7==0)
continue;
Total +=number;
}
Return the total;
}

Int
The main (void)
{
The string line;

While (getline (cin, line)) {
Cout & lt; }

return 0;
}

CodePudding user response:

I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related