当前位置: 首页 > news >正文

十月末

  • 由于上周太忙碌,忘记了自己写的代码存在哪有点找不着了只剩如下还找得到的代码

高速公路罚判:

#include <stdio.h>
int main()
{int x,y;scanf("%d %d",&x,&y);if(x>=(1*y)+(0.5*y)){printf("吊销驾驶证"); }else if(x>=(1*y)+(0.1*y)){printf("罚款200元"); }else if(x<=(1*y)+(0.1*y)){printf("未超速"); }return 0;
}

学生成绩统计:

#include <stdio.h>int main()
{int n,number;scanf("%d",&n);double average;double score;double total=0.00;for(int i=1;i<=n;i++){scanf("%lf",&score);total+=score;average=total/n;if(score<60){number++;}		}printf("%.2f %d",average,number);return 0;
}
#include <stdio.h>
int main()
{char a;int letter=0;int blank=0;int digit=0;int other=0;int i;     for(i=1; ;i++){a=getchar();if((a>='a'&&a<='z')||(a>='A'&&a<='Z')){letter++;}else if(a==' '){blank++;}else if(a>='0'&&a<='9'){digit++;}else if(a=='\n'){break;}else{other++;}}printf("letter = %d, blank = %d, digit = %d, other = %d",letter,blank,digit,other);return 0;
}
include <stdio.h>
int fn(int a,int n);
int main()
{int a,n;int i;int sum=0;scanf("%d %d",&a,&n);if(a<=0||n<=0){return 1;}for(i=1;i<=n;i++){sum+=fn(a,i);}printf("%d",sum);return 0;
}int fn(int a,int n)
{int result = 0;int i;for(i=0;i<n;i++){result = result * 10 + a; //让每层循环位数向前移一位 }return result;
}
#include <stdio.h>
int fib(int n);
int main()
{int m,n,i;int num;scanf("%d %d",&m,&n);if(m>=1&&n<=10000&&m<=n){for(i=1;i<=n;i++)          //要让i=1,因为后面才判断所得值是否在m,n内 {num = fib(i);if(num>n){break;}else if(num>=m){printf("%d ",num);}}	}return 0;
} // 算第n项斐波那契数
int fib(int n)
{int number;if (n == 1 || n == 2) {return 1;  // F(1) = 1, F(2) = 1}// number = fib(n - 1) + fib(n - 2);  // F(n) = F(n-1) + F(n-2)//return number;        //递归函数效率较低//用迭代法int i;int a=1;int b=1;int c;for(i=3;i<=n;i++){c=a+b;a=b;b=c;} return b;
}
#include <stdio.h> 
int fac(int n);
int main()
{int n;scanf("%d",&n);if(n>=1&&n<=10){int factorial=fac(n);printf("%d",factorial);}return 0;
}int fac(int n)
{int i;int result=1;for(i=1;i<=n;i++){result*=i;}return result;
}
#include <stdio.h>
int sum(int x);int main()
{int x,number;scanf("%d",&x);if(x>=0&&x<=999){number=sum(x);printf("%d",number);}return 0;
} int sum(int x)
{int sum=0;int ge,shi,bai;ge=x%10;shi=(x/10)%10;bai=x/100;sum=ge+shi+bai;return sum;
}
#include <stdio.h>
#include <math.h>
int isPrime(int n);
int main()
{int i;for(i=100;i<=200;i++){if(isPrime(i)){printf("%d ",i);}}return 0;
} int isPrime(int n)
{if(n<=1){return 0;}int i;for(i=2;i<=sqrt(n);i++){if(n%i==0){return 0;}}return 1;
}
#include <stdio.h>
float average(float a[],int n);
int main()
{int i,n,aver;float scores[10];int n;scanf("%d",&n);if(n<1||n>10){return 1;}for(i=0;i<n;i++){scanf("%f",&scores[i]);}aver=average(scores,n);printf("average=%.1f\n",aver);return 0;
}float average(float a[],int n)
{int i;float sum=0.0;for(i=0;i<=n;i++){sum+=a[i];}return sum/n;
}
/*
#include <stdio.h>int main() 
{int number;int sum = 0;while (1) {scanf("%d", &number); if (number <= 0) { break;}if (number % 2 != 0) { sum += number; }}printf("%d", sum);return 0;
}
*//*
#include <stdio.h>
int main()
{int n;int i;int molecule=2;int denominator=1;double sum=0.0;scanf("%d",&n);for(i=1;i<=n;i++){sum+=(double)molecule/denominator;int temp;temp=molecule;molecule+=denominator;denominator=temp;}printf("%.2f",sum);return 0;}
*//*
#include <stdio.h>void digit(int number){if (number < 0) {number = -number; }if (number == 0){printf("0\n");return;}int divisor = 1;while (number / divisor >= 10) {divisor *= 10;}while (divisor > 0) {int digit = number / divisor; printf("%d", digit);          number %= divisor;            divisor /= 10;                if (divisor > 0) {printf(" ");}}printf("\n"); 
}int main() 
{int number;scanf("%d", &number);digit(number);return 0;
}
*/
/*
#include <stdio.h>
int main()
{int fahr, lower, upper;double celsius;scanf("%d",&lower);scanf("%d",&upper);if (lower <= upper){for (fahr = lower; fahr <= upper; fahr++){celsius = (5.0 / 9) * (fahr - 32);printf("%d %.1f\n", fahr, celsius);}}else{printf("Invalid Value!");}return 0;
}
*//*
#include <stdio.h>
int main()
{int x;double fee;scanf("%d",&x);if(x<0){printf("Invalid Value!");}else if(x<=50){fee=0.53*x;printf("%.2f",fee);}else{fee=(0.53*50) + (x-50)*(0.05+0.53);printf("%.2f",fee);}return 0;
}
*//*
#include <stdio.h>double f(double x);int main()
{double x;double y;scanf("%lf",&x);y=f(x);printf("f(%.2f) = %.2f",x,y);return 0;
} double f(double x)
{double i;if(x<0){i=0;}else if(x>=0&&x<=15){i=4.0/3*x;}else{i=2.5*x-10.5; }return i;
}
*/
/*
#include <stdio.h>
int main()
{int fahr, lower, upper;double celsius;scanf("%d",&lower);scanf("%d",&upper);if (lower <= upper){for (fahr = lower; fahr <= upper; fahr++){celsius = (5.0 / 9) * (fahr - 32);printf("%d %.1f\n", fahr, celsius);}}else{printf("Invalid Value!");}return 0;
}
*/
/*
#include <stdio.h>
#include <math.h>
int main()
{int n,num;int i;scanf("%d",&n);if(n<=1){printf("No!");}else if(n==2){printf("Yes!");}else{num=sqrt(n)+1;for(i=2;i<=n;i++){if(n%i==0){break;}}if(i>num){printf("YES");}else{printf("No!");	}}return 0;} 
*//*
#include <stdio.h>
int main()
{int n,i;int factorial=1;int sum=0;scanf("%d",&n);for(i=1;i<=n;i++){factorial*=i;sum+=factorial;}printf("%d",sum);
}
*/
/*
#include <stdio.h>
int main()
{int n,i,x,x1,x2;scanf("%d",&n);if(n<1||n>46){printf("Invalid.");}x1=1;x2=1;printf("%10d%10d",x1,x2);if(n>=1&&n<=46){for(i=3;i<=n;i++){x=x1+x2;printf("%10d",x);if(i%5==0){printf("\n");}x1=x2;x2=x;}}printf("\n");return 0;
}/*
#include <stdio.h>
#include <math.h>
int main()
{int m,n,k,i;int count=0;int flag;int limit;scanf("%d %d",&m,&n);if(m<1||n>500||m>n){return 1;}else {for(k=m;k<=n;k++){if(k<=1){flag=0;}else if(k==2){flag=1;}else{flag=1;limit=sqrt(k)+1;for(i=2;i<=limit;i++){if(k%i==0){flag=0;break;}}}if(flag==1){printf("%d ",k);count++;if(count%10==0){printf("\n");}}}}return 0;}
*//*
#include <stdio.h>
int main()
{int n1,n2,n5;int money,flag;int sum=0;flag=1;scanf("%d",&money);for(n5=money/5;(n5>=0)&&(flag==1);n5--){for(n2=money/2;(n2>=0)&&(flag==1);n2--){for(n1=money/2;(n1>=0)&&(flag==1);n1--){if((n5*5+n2*2+n1)==money){sum=n5+n2+n1;printf("%d %d %d %d",n5,n2,n1,sum);flag=0;}}}}return 0;
} 
*//*
#include <stdio.h>
int main()
{int men,women,children;int n,count;scanf("%d",&n);count=0;for(men=0;men<=n;men++){for(women=0;women<=n;women++){for(children=0;children<=n;children++){if((men+women+children==n)&&(men*3+women*2+children*0.5==n)){printf("%d,%d,%d\n",men,women,children);count++;}}}}if(count==0){printf("None");}return 0;}
*/
/*
#include <stdio.h>
int main()
{int n,i,j;double e=1.0000;double denominator;scanf("%d",&n);for(i=1;i<=n;i++){denominator=1.0000;for(j=1;j<=i;j++){denominator*=j;}e+=1.0/denominator;}printf("%.4f",e);return 0;}
*/
/*
#include <stdio.h>int main() {int n, i, j;double e = 1.0; scanf("%d", &n);for (i = 1; i <= n; i++) {double factorial = 1.0; for (j = 1; j <= i; j++) {factorial *= j; }e += 1.0 / factorial; }printf("%.4f\n", e);return 0;
}
*//*
#include <stdio.h>int main() {int n;int i;int j;double e = 1.0;scanf("%d", &n);for (i = 1; i <= n; i++) {double factorial = 1.0;for (j = 1; j <= i; j++) {factorial *= j;}e += 1 / factorial; }printf("%.4f\n", e);return 0;
}
*/
/*
#include <stdio.h>
int main()
{int point,n5,n2,n1;int sum;scanf("%d",&point);for(n5=1;n5<=point/5;n5++){for(n2=1;n2<=(point/5)/2;n2++){for(n1=1;n1<=(point-((point/5)/2));n1++){if(n1>=1){sum=n5+n2+n1;printf("%d %d %d %d\n",n5,n2,n1,sum);}}}}return 0;
}
*/
/*
#include <stdio.h>
int main()
{int n,i,ge,shi,bai;int number;scanf("%d",&n);if(n>=3&&n<=7){for(i=1;i<=n;i++){if(number==)			}}return 0;
}
*//*
#include <stdio.h>
void money(int amount)
{int n5,n2,n1;int count=0;for(n5=1;n5*5<=amount;n5++){for(n2=1;n2*2<=amount;n2++){n1=amount-(n2*2+n5*5);if(n1>=1){printf("%d %d %d %d\n",n5,n2,n1,n5+n2+n1);count++;}}}if(count=0){return 1;}}int main()
{int mount;int amount;scanf("%d",&amount);if(amount>8&&amount<100){money(amount);}else{return 1;}return 0;
}
*/
/*
#include <stdio.h>
int gcd(int a,int b)
{while (b != 0){int temp = b;b = a % b;a = temp;}return a;
}
int lcm(int a,int b)
{return (a*b)/gcd(a,b);}
int main()
{int m,n;scanf("%d %d",&m,&n);int greatest=gcd(m,n);int least=lcm(m,n);printf("%d\n",greatest);printf("%d\n",least);return 0;
}
*//*
#include <stdio.h>
double real,imag;
int main()
{double imag1,imag2,real1,real2;void add(double real1,double imag1,double real2,double imag2);void prod(double real1,double imag1,double real2,double imag2);scanf("%d",&real2,&imag2);add(real1,imag1,real2,imag2);prod(real1,imag1,real2,imag2);printf("%.2f+%.2fi\n",real,imag);return 0;
}void add(double real1,double imag1,double real2,double imag2)
{real=real1+real2;imag=imag1+imag2;
}
void prod(double real1,double imag1,double real2,double imag2)
{real=real1*real2-imag1*imag2;imag=real1*imag2+real2*imag1;
}
*/#include <stdio.h>
#include <stdlib.h>
#include <math.h>double funcos(double e, double x);
double factorial(int n);
int main() 
{double e, x;scanf("%lf %lf", &e, &x);double result = funcos(e, x);printf("%.6f", result);return 0;
}double funcos(double e, double x) 
{int n = 0;double cos = 0;double precision = 1; while (fabs(precision) >= e) {cos += precision;n++;precision = (pow(-1, n) * pow(x, 2 * n)) / factorial(2 * n);}return cos;
}double factorial(int n) 
{int i;double result = 1;for (i = 1; i <= n; i++){result *= i;}return result;
}

http://www.mrgr.cn/news/66340.html

相关文章:

  • 数据结构——二叉树(续集)
  • vue框架简介
  • 信息技术的发展趋势与挑战
  • ubuntu知识点滴积累
  • wpf 制作丝滑Flyout浮出侧边栏Demo (Mahapps UI框架)
  • 基于redis实现延迟队列
  • Nginx配置文件编写示例
  • Java中查找与排序算法探究
  • 阿里云服务器 篇十(加更):自动定时备份CSDN博客内容:优化内存和解决图片展示等问题
  • 5分钟上手 Kubernetes:精简实用的 Kubectl 命令速查宝典!
  • 【ESP32+MicroPython】热点模式及网页控制
  • 产品增长之付费推广
  • 光伏设计软件如何快速上手?
  • 【万字详文介绍】:迭代扩张卷积神经网络(IDCNN)
  • 模拟实现C库函数~
  • 【OJ题解】在字符串中查找第一个不重复字符的索引
  • 华为HarmonyOS借助AR引擎帮助应用实现虚拟与现实交互的能力5-识别平面语义
  • 【LeetCode】【算法】146. LRU缓存
  • Python学习笔记-生成器的应用与原理
  • 好看的超清4K视频素材去哪儿找?下载素材资源网站推荐
  • AI大模型重塑软件开发:流程、优势、挑战与展望
  • 「C/C++」C/C++标准库 之 #include<cctype> 字符分类处理库
  • 牛客周赛 66 F 小苯的字符提前
  • 进程的调度(超详细解读)
  • Day 49 || 1143.最长公共子序列、1035.不相交的线、 53. 最大子序和 、392.判断子序列
  • Java入门(8)--反射机制