#include "stdio.h"
main()
{
int sum=1,i
for(i=0i<9i++)
sum=(sum+1)*2
printf("猴子共摘了%d个桃子。\n",sum)
}
#include<iostream>using namespace std
void main()
{
int a=1,n,i=1
cout<<"第几天后"<<endl
cin>>n
while(i<n)
{
a=(a+1)*2
i++
}
cout<<"第一天的桃子数"<<a<<endl
}
public class Monkey {private String color
private String sex
public Monkey(String color,String sex) {
this.color = color
this.sex = sex
}
public Monkey(String color) {
this.color = color
this.sex = "公"
}
public Monkey(){}
public String getColor() {
return color
}
public void setColor(String color) {
this.color = color
}
public String getSex() {
return sex
}
public void setSex(String sex) {
this.sex = sex
}
public int add(int p1,int p2,int p3) {
return p1+p2+p3
}
public int add(int p1,int p2) {
return p1+p2
}
}
public class Zoo {
public static void main(String[] args) {
Monkey g = new Monkey("黑")
Monkey l = new Monkey("红","母")
int p1 = g.add(1, 2)
int p2 = l.add(1, 2, 3)
System.out.println(g.getSex()+":"+p1)
System.out.println(l.getSex()+":"+p2)
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)