您好,欢迎访问一九零五行业门户网

打印n个数字,使它们的和是一个完全平方数

给定n个数字,程序必须找到这n个数字的和为一个完全平方数
input : 5output : 1 3 5 7 91+3+5+7+9=25 i.e (5)^2
算法start step 1 : declare a macro for size let’s say of 5 and i to 1 step 2: loop while till i<=size step 2.1 -> printing (2*i)-1 step step 2.2 -> incrementing i with 1 step step3-> end loop whilestop
example 的中文翻译为:示例#include <stdio.h># define size 5int main() { int i=1; while(i<=size) { printf("
%d",((2*i)-1)); i++; }}
输出如果我们运行上面的程序,它将生成以下输出
13579
以上就是打印n个数字,使它们的和是一个完全平方数的详细内容。
其它类似信息

推荐信息