|
发表于 2020-11-15 20:09:33
|
显示全部楼层
本帖最后由 baige 于 2020-11-15 20:30 编辑
- #include <stdio.h>
- #include <math.h>
- void solve(int num){
- int temp = sqrt(num);
- if(temp*temp == num){
- printf("%d是平方数",num);
- }else printf("%d不是平方数",num);
- putchar('\n');
- }
- int main(){
- int num;
- scanf("%d",&num);
- slove(num);
- return 0;
- }
复制代码- #include <stdio.h>
- #include <math.h>
- double solve(double profit){
- double x[] = {0.1*10,0.075*10,0.05*20,0.03*20,0.015*40,0.01};
- double ans = 0;
- if(profit <= 10) ans = profit * 0.1;
- else if(profit <= 20) ans = x[0] + (profit-10)*0.075;
- else if(profit <= 40) ans = x[0] + x[1] + (profit-20)*0.05;
- else if(profit <= 60) ans = x[0] + x[1] + x[2] +(profit-40)*0.03;
- else if(profit <= 100) ans = x[0] + x[1] + x[2] +x [3] + (profit-60)*0.015;
- else ans = x[0]+x[1]+x[2]+x[3]+x[4]+(profit-100)*x[5];
- return ans;
- }
- int main(){
- double profit;// 利润
- scanf("%lf",&profit);
- double ans = solve(profit);
- printf("应发放的奖金为:%.3lf万元",ans);
- return 0;
- }
复制代码- #include <stdio.h>
- int main(void){
- int sum = 0;
- for(int i = 100; i < 1000; ++i){
- int temp = i, ret = 0;
- while(temp){
- int t = temp%10;
- ret += t*t*t;
- temp /= 10;
- }
- if(i == ret){
- sum += i;
- }
- }
- printf("%d",sum);
- return 0;
- }
复制代码 |
|