//我的理解,虽然一开始没写出来呜呜呜(从E到A) #include<stdio.h> intmain() { int x; int i=1; for (x = 4;x<=10000; x+=4) { int a=x; while (x % 4 == 0 && i <= 5) { x = 1.25 * x + 1; i++; } if ((x - 1) % 20 == 0 && i == 6 ) { printf("Total number of fish catched=%d\n", x); }else x=a; i =1; } return0; }
//这是直接从A到E的方法(自己写的!!!!!) #include<stdio.h> intmain() { int x=626; int i=1; int n=x-1; for (n;n<=3200; n+=5) { while ((x-1) % 5 == 0 && i <= 5) { x = (x - 1)*0.8; i++; } if ( i == 6) { printf("Total number of fish catched=%d\n", n-4); }else x=n+1; i =1; } return0; }
#include<stdio.h> #define RATE 0.01875 #define MONTHS 12 #define CAPITAL 1000 #define YEARS 5 main() { int i; double deposit = 0; for (i = 0; i < YEARS; i++) { deposit = (deposit + CAPITAL) / (1 + RATE * MONTHS); } printf("He must save %.2f at the first year.\n", deposit); }
#include<stdio.h> intmain(){ int a,b,c; int sum=0,Sum=0; scanf("%4d-%2d-%2d",&a,&b,&c); int MAX[12]={31,28,31,30,31,30,31,31,30,31,30,31}; //利用数组记录每月月数 //闰年改二月的日期 if(a%4==0&&a%100!=0&&a%400==0) MAX[1]=29; //计算?月距离一月一号过了多少天 for(int i=1;i<b;i++){ sum+=MAX[i]; } for(int j=1990;j<a;j++){ if(a%4==0&&a%100!=0&&a%400==0) Sum+=366; else Sum+=365; } int ret=(sum+Sum+c)%5; if(b<0||b>12||c<0||c>MAX[b-1]){ printf("Invalid input."); exit(0); }else{ if(ret==0||ret==4) printf("He is having a rest."); else printf("He is working."); } return0; }
rand()的使用方法
简单点:rand()%(b-a+1)+a表示【a,b】区间
一般使用:
1 2 3 4 5 6 7 8 9 10 11 12
#include<stdio.h> #include<stdlib.h> #include<time.h> intmain(){ int a=98; int b=678; int number; srand(time(0)); number=rand()%(b-a+1)+a; printf("%d",number); return0; }
Dear Miss.? When i think of you'I'm reminded of the beautiful plains of Iowa.The distance between us is breaking my spirit. My time and experiences without you are meaningless to me. Falling in love with you was the easiest thing i have ever done.Nothing matters but you.