害死人不偿命的(3n+1)猜想 (练习题33)
#include <stdio.h>
int main(){
int p=0;
int n;
scanf("%d",&n);
while(n>1){
if(n%2!=0){
n=(3*n+1)/2;
p++;
}
else{
n=n/2;
p++;
}
}
printf("%d\n",p);
return 0;
}
挖掘机技术哪家强(真题22)
#include <stdio.h>
typedef long long int;
int main(){
int N;
int school[100001]={};
scanf("%d",&N);
int id;
int score=0,max=0;
for(int i=0;i<N;i++){
scanf("%d %d",&id,&score);
school[id]+=score;
if(school[id]>school[max]){
max=id;
}
}
printf("%d %d",max,school[max]);
return 0;
}
跟奥巴马一起编程(真题26)
#include <stdio.h>
int main(){
int n;
char c;
scanf("%d %c",&n,&c);
int x=(n+1)/2,y=n;
for(int i=0;i<x;i++){
for(int j=0;j<n;j++){
if(i==0||i==x-1||j==0||j==n-1)
printf("%c",c);
else
printf(" ");
}
printf("\n");
}
return 0;
}