輸入:
3
216
121
2005
結果:
198
0
1979
3是總共輸入的數字有幾組
198+1+9+8=216
121沒有所以輸出是0
1979+1+9+7+9=2005
程式碼:
#include <stdio.h>
int genBig(int n)//剝皮法
{
int ans=n;
while(n>0)
{
int now=n%10;
n/=10;
ans+=now;
}
return ans;
}
int main()
{
int T;
scanf("%d",&T);
for(int t=0;t<T;t++)//輸入
{
int n;
scanf("%d",&n);
int ans=0;
for(int small=1;small<=n;small++)
{
if(genBig(small)==n)
{
ans=small;
break;
}
}
printf("%d\n",ans);
}
}
憤怒鳥
PImage imgBird;
void setup(){
size(500,400);
imgBird=loadImage("bird.png");
imageMode(CENTER);
}
void draw(){
background(255);
image(imgBird,mouseX,mouseY,100,100);
}
執行結果:
拉線程式碼:
PImage imgBird;
void setup(){
size(500,400);
imgBird=loadImage("bird.png");
imageMode(CENTER);
}
float birdX=100,birdY=300,oldX,oldY;
void draw(){
background(255);
image(imgBird,birdX,birdY,100,100);
if(mousePressed) line(birdX,birdY,oldX,oldY);
}
void mousePressed(){
oldX=birdX;
oldY=birdY;
}
void mouseDragged(){
birdX=mouseX;
birdY=mouseY;
}
沒有留言:
張貼留言