打印n个数字,使它们的和成为一个完美的平方
给定n个数字,程序必须找到总和为完美平方的n个数字
Input : 5 Output : 1 3 5 7 9 1+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 While
STOP示例
#include <stdio.h>
# define SIZE 5
int main() {
int i=1;
while(i<=SIZE) {
printf("\n %d",((2*i)-1)); i++;
}
}输出结果
如果我们运行上面的程序,那么它将生成以下输出
1 3 5 7 9
热门推荐
1 狗狗技能训练
5 如何训练狗狗笑
6 狗狗训练排便
9 狗狗响片训练
10 如何训练狗狗不捡食
11 狗狗尿训练
12 怎么训练狗狗找东西
13 狗狗训练站立
14 狗狗训练飞盘
15 鞍山狗狗训练
16 怎样训练泰迪狗狗谢谢
17 狗狗外出训练
18 怎么训练金毛狗狗大小便