1到1000的程序怎么写

1.1*10*100*1000#include <stdio.h>
//1*10*100*1000*10000 。..的c语言程序怎么写
//至少有两种思路,一种是写个大数类,再直接算乘法
//二是偷个懒,计算结果会有几个0,直接输出结果
//1*10*100*1000*10000* 。*1(n-1个0)
//0 1 2 3 4。。。n-1
//类加,即结果会有 (1+n-1)*(n-1)/2个0
//下面采用第二种方法
int main()
{
int n,i=1;
int k=0;
scanf("%d",&n);
k=n*(n-1)/2;
printf("1");
while(i<=k){
printf("0");
++i;
}
printf("\n");
return 0;
}
2.写一个程序关于求1到1000各位数字之和为15的数用python 写的:
def main():
count = [x for x in range(1001)]
for num in count:
if getSum(num) == 15:
print num
#数字所有位之和
def getSum(num):
sum = 0
while num != 0:
a = num % 10
num = num / 10
sum += a
return sum
if __name__ == '__main__':
main()
更为合理的写法:
def main():
print filter(getNum, range(1001))
#是否满足条件
def getNum(num):
if getSum(num) == 15:
return num
#数字所有位之和
def getSum(num):
sum = 0
while num != 0:
a = num % 10
num = num / 10
sum += a
return sum
if __name__ == '__main__':
main()
3.c编程中怎么写1到1000所有的质数相加的和#include <stdio.h>
main()
{
int s=0,i,j,temp=0;
for(i=2;i<1000;i++)
{
for(j=2;j<i;j++)
{
if(i%j==0)
{
temp=1;
break;
}
}
if(temp==0)
{
s+=i;
【1到1000的程序怎么写】}
temp=0;
}
printf("%d",s);
}你试试 。
我用10以内的质数算了下,是正确的 。
4.编写个从1加到1000的JAVA程序这种方法实用一些 。
public class 递归 {
static int way(int N){
int s=0;
if(N>=1)s=N+way(N-1);
return s;
}
public static void main(String[]arg){
int NUM=1000;//定义最大的数
System.out.println(way(NUM));
}
}
5.1*10*100*1000#include //1*10*100*1000*10000 。
..的c语言程序怎么写//至少有两种思路,一种是写个大数类,再直接算乘法//二是偷个懒,计算结果会有几个0,直接输出结果//1*10*100*1000*10000* 。*1(n-1个0)//0 1 2 3 4。
n-1 //类加,即结果会有 (1+n-1)*(n-1)/2个0//下面采用第二种方法int main(){ int n,i=1; int k=0; scanf("%d",&n); k=n*(n-1)/2; printf("1"); while(i<=k){ printf("0"); ++i; } printf("\n"); return 0;} 。
6.写一个程序关于求1到1000各位数字之和为15的数用python 写的: def main(): count = [x for x in range(1001)] for num in count: if getSum(num) == 15: print num#数字所有位之和def getSum(num): sum = 0 while num != 0: a = num % 10 num = num / 10 sum += a return sumif __name__ == '__main__': main() 更为合理的写法: def main(): print filter(getNum, range(1001))#是否满足条件def getNum(num): if getSum(num) == 15: return num#数字所有位之和def getSum(num): sum = 0 while num != 0: a = num % 10 num = num / 10 sum += a return sumif __name__ == '__main__': main() 。
7.编写一个程序计算出1到1000为3位数的所有数之和public class TestSum {
public static void main(String[] args) {
int sum = 0;
for(int i=1;i<=1000;i++){
if(i%3==0){
sum += i;
}
}
System.out.println("1到1000为3的倍数的所有数之和="+sum);
}
}
8.1到1000的英文怎么写one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty twenty one twenty two twenty three twenty four twenty five twenty six twenty seven twenty eight twenty nine thirty thirty one thirty two thirty three thirty four thirty five thirty six thirty seven thirty eight thirty nine forty forty one forty two forty three forty four forty five forty six forty seven forty eight forty nine fifty fifty one fifty two fifty three fifty four fifty five fifty six fifty seven fifty eight fifty nine sixty sixty one sixty two sixty three sixty four sixty five sixty six sixty seven sixty eight sixty nine seventy seventy one seventy two seventy three seventy four seventy five seventy six seventy seven seventy eight seventy nine eighty eighty one eighty two eighty three eighty four eighty five eighty six eighty seven eighty eight eighty nine ninety ninety one ninety two ninety three ninety four ninety five ninety six ninety seven ninety eight ninety nine one-hundred The numbers from 101 to 999 put a hundreds value (one hundred, two hundred) in front of the last two digits as above : 101 one hundred one 111 one hundred eleven 121 one hundred twenty-one 201 two hundred one 211 two hundred eleven 221 two hundred twenty-one 1000 one thousand The numbers 1001 to 999,999 put the thousands value (one thousand, two thousand, eleven thousand, one hundred thousand) as a separate number followed by thousand), then the number as from 1 to 999. 1001 one thousand one (also one thousand and one) 1011 one thousand eleven 1111 one thousand one hundred eleven 9999 nine thousand nine hundred ninety-nine 10000 ten thousand 11000 eleven thousand 21000 twenty-one thousand 21111 twenty-one thousand, one hundred eleven (note comma often used) 110000 one hundred ten thousand (also one hundred and ten thousand) 111000 one hundred eleven thousand (also one hundred and eleven thousand) 999999 nine hundred ninety-nine thousand, nine hundred ninety-nine 。