解题思路:本来是用1解答的,参考别人的解题思路后觉得2更喜欢所以一起发了。
注意事项:
参考代码:
1:
#include<stdio.h>
int main()
{
int n,i,t=1;
while(scanf("%d",&n)!=EOF){
for(i=1;i<n;i++){
t=(t+1)*2;
}
printf("%d\n",t);
t=1;
}
}
2:
#include<stdio.h>
int number(int n)
{
if(n==1) return 1;
else return (number(n-1)+1)*2;
}
int main()
{
int n;
while(scanf("%d",&n)!=EOF){
printf("%d\n",number(n));
}
}
0.0分
0 人评分
C语言训练-素数问题 (C语言代码)浏览:998 |
九宫重排 (C++代码)浏览:1334 |
C语言程序设计教程(第三版)课后习题10.5 (C语言代码)浏览:552 |
WU-格式化数据输出 (C语言代码)浏览:1755 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:840 |
数对 (C语言代码)浏览:702 |
简单的a+b (C语言代码)浏览:546 |
C语言程序设计教程(第三版)课后习题10.1 (C++代码)浏览:503 |
拆分位数 (C语言代码)浏览:444 |
2004年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:582 |