Welcome to Exchange Discussions!
@2-1#include <fstream>using namespace Std;ifstream fin ("aplusb.in"); Ofstream fout ("aplusb.out"); int main () {int N while (fin>>n) {int count = 0; Computes the number of bits while (n) {count++; n/= 10; } fout << count << Endl; } return 0;} @2-2#include <fstream>using namespace Std;ifstream fin ("aplusb.in"); Ofstream fout ("aplusb.out"); int main () {int N for (int i = +; I < i++) {int A = i/100, B = i%100%10, C = i% 10; if (a*a*a+b*b*b+c*c*c = = i) fout << i << "^_______________________________________________________^" << Endl; else Fout << "It is not~" << Endl; } return 0;} @2-3#include <fstream>using namespace Std;ifstream fin ("aplusb.in"); Ofstream fout ("aplusb.out"); int main () {int A, B, C, I; while (Fin >>a>>b>>c) {for (i = ten; I <=, i++) {if (i%3 = = a && i%5==b &am P;&amP I%7==c) {fout << i << Endl; Break }} if (i = = 101) fout << "No answer" << Endl; } return 0;} @2-4#include <fstream>using namespace Std;ifstream fin ("aplusb.in"); Ofstream fout ("aplusb.out"); int main () {int N for (int i = 1; I <=5; i++) {//Output spaces 0-4 for (int j = 1; J <= I-1; j + +) Fout << ""; Output # 11-2i for (int k = 1; k <= 11-2*i; k++) fout << "#"; Fout << Endl; } return 0;} @2-5#include <fstream>using namespace Std;ifstream fin ("aplusb.in"); Ofstream fout ("aplusb.out"); int main () {int N while (Fin >> n) {int a[n], m, i = 0, count = 0; while (i < n) fin >> a[i++]; Fin >> m; for (i = 0; i < n; i++) {if (A[i] < m) count++; } fout << count << Endl; } return 0;} @2-6#include <fstream> #include <iostream> #include &lT;iomanip>using namespace Std;ifstream fin ("aplusb.in"); Ofstream fout ("aplusb.out"); int main () {int n; while (Fin >> N) {double count = 0; int i = 1; while (i <= N) count + = 1.0/i; Fout << fixed<< setprecision (3) << count << Endl; } return 0;} @2-7#include <fstream> #include <iostream> #include <iomanip>using namespace std;ifstream fin (" Aplusb.in "); Ofstream fout (" aplusb.out "); int main () {double count = 0; int i = 1, flag =-1; while (1.0/i >= 1.0e-6) {flag *= -1;//flag inverse, each item is changed to sign double temp = 1.0/i; Count + = flag * TEMP; i + = 2; } fout << count << Endl; return 0;} @2-8#include <iostream> #include <fstream> #include <iomanip>using namespace std;ifstream fin (" Aplusb.in "); Ofstream fout (" aplusb.out "); int main (void) {Long long n, m; while (Fin >> n >> m) {long Long loop = n; Double sum = 0.0; while (Loop <= m) {Double add = 1.0/(Loop*loop); sum + = add; loop++; } fout << Fixed << setprecision (5) << sum << Endl; } return 0;} @2-9#include <iostream> #include <fstream> #include <iomanip>using namespace std;ifstream fin (" Aplusb.in "); Ofstream fout (" aplusb.out "); int main (void) {int A, b, C; while (Fin >> a >> b >> c) {fout << fixed << setprecision (c) << a*1.0/b << Endl } return 0;} @2-10#include <iostream> #include <fstream> #include <string.h>using namespace std;ifstream fin (" Aplusb.in "); Ofstream fout (" aplusb.out "); int main (void) {int ABC, DEF, Ghi, hash[10]; for (ABC = 123; ABC <= 329; abc++) {memset (hash, 0, sizeof (hash)); def = 2*abc, ghi = 3*ABC; HASH[DEF/100] = 1, HASH[DEF%100/10] = 1, hash[def%10] = 1; HASH[ABC/100] = 1, HASH[ABC%100/10] = 1, hash[abc%10] = 1; HaSH[GHI/100] = 1, HASH[GHI%100/10] = 1, hash[ghi%10] = 1; int countone = 0; for (int i = 1; i < i++) {if (hash[i] = = 1) countone++; if (Countone = = 9) fout << "Abc:def:ghi is:\n" << ABC << ":" << def << ":" & lt;< Ghi <<endl; } return 0;}
Rujia Algorithm Competition Introduction Classic second unit exercise answer self-editing