#include "stdio.h"
void main()
{
int num;
printf("please input a num \n");
scanf_s("%d", &num);
int sum = 0;
while (num)
{
sum += num % 10;
num /= 10;
}
printf("sumarry is:%d", sum);
}
狮子座的男孩的博客Ⅰ、用for循环求斐波那契数列问题: ①、//代码摘下直接可以运行 //斐波那契数列问题 #include<stdio.h> int main() { int t,s,a1,a2,n; s=0;a1=1;a2=1; printf(“Please input the n of Fibonacci!\n”); ...
狮子座的男孩的博客Ⅰ、用do-while求n的阶乘: ①、//代码摘下直接可以运行 //n的阶乘(n!) #include<stdio.h> int main() { int t,n,result; result=1; printf(“Please input the number of n!\n”); scanf("%d",&n); t=n; ...
c栈算法小辰哥的博客 想想之前在写循环结构的时候是怎么计数的? 想起来了!直接定义变量,每出现一次就加一呗! int j = 0; int o = 0; int p = 0; int q = 0; int r = 0; int s = 0; int x = 0; for (x; x ; x++)//(分别记录各个分数...