// 判断整数的正因子数目
//#include<stdio.h>
//#include<math.h>
//
//int main()
//{
// int n;
// int i,count=2;
// scanf("%d",&n);
// int len=(int)sqrt((double)n);
// for(i=2;i<=len;i++)
// {
// if(0==n%i)
// if(i==n/i)
// count++;
// else
// count+=2;
// }
// printf("正因子数目:%d\n",count);
//}
// 输出位数
//#include<stdio.h>
//int main()
//{
// int n,i,count=0;
// scanf("%d",&n);
// for(i=1000000000;i>=1;i=i/10)
// {
// if(n/i!=0)
// count++;
// }
// printf("%d\n",count);
// return 0;
//}
//#include<stdio.h>
//#include<stdlib.h>
//#include<memory.h>
//#include<string.h>
//#include<assert.h>
//#define MAX_LENGTH 1000
//
//int main()
//{
// FILE *fp = fopen("a.txt","r");
// long int pos;
// char * str = (char*)malloc(MAX_LENGTH);
// assert(str);
// errno=0;
// if(!fp)
// {
// fprintf(stderr,"a.txt failed.Erroe code:%s\n",strerror(errno));
// return -1;
// }
// fscanf(fp,"%s",str);
// puts(str);
// fseek(fp,8L,SEEK_SET);
// pos = ftell(fp);
// if(-1L == pos && errno <= 0)
// {
// fprintf(stderr,"返回a.txt的指针当前读取位置失败. Error code: %s\n",strerror(errno));
// return -1;
// }
// printf("指针当前位置为:%ld\n",pos);
// fscanf(fp,"%s",str); puts(str);
// fseek(fp,20L,SEEK_SET);
// fscanf(fp,"%s",str); puts(str);
// fseek(fp,pos,SEEK_SET);
// fscanf(fp,"%s",str); puts(str);
// fclose(fp); // 关闭文件
// free(str);
// return 0;
//}
//#include "stdio.h"
//#include <stdlib.h>
//int main()
//{
// FILE *fp;
// fp=fopen("myfile.txt","w");
// if(fp==NULL)
// printf("File can not be opened\n");
// else
// printf("File opened for writing\n");
// if(fclose(fp)!=0)
// printf("File not be closed\n");
// else
// printf("File is now closed\n");
//
// FILE * fp;
// char ch;
// fp = fopen("myfile.txt","r");
// if(fp==NULL)
// printf("file cannot be opened\n");
// while((fgetc(fp))!=EOF)
// fputc(ch,stdout);
// fclose(fp);
// return 0;
//}
// 水仙花数 有问题啊
//#include<stdio.h>
//int main()
//{
// int i,count=0;
// for(i=100;i<999;i++)
// {
//
// if(i==((i=i/100)*(i/100)*(i/100)+(i/10%10)*(i/10%10)
// *(i/10%10)+(i%10)*(i%10)*(i%10)));
// {
// printf("%d",i);
// count++;
// }
// }
// printf("%d",count);
// return 0;
//}
// 韩信点兵
//#include<stdio.h>
//int main()
//{
// int x,count=0;
// int a,b,c;
// scanf("%d %d %d",&a,&b,&c);
// for(x=10;x<=100;x++)
// {
// if(x%3==a && x%5==b && x%7==c)
// {
// printf("%d\n",x);
// count ++;
// }
// }
// if(count==0)
// printf("No answers");
// return 0;
//}
// 倒三角
//#include<stdio.h>
//int main()
//{
// int n,i,j,k;
// scanf("%d",&n);
// for(i=n;i>=1;i--)
// {
// for(k=0;k<n-i;k++)
// printf(" ");
// for(j=1;j<=2*i-1;j++)
// printf("*");
// printf("\n");
// }
// return 0;
//}
// stat
//#include<stdio.h>
//int main()
//{
// int arr[100];
// int n,m,i,count=0;
// scanf("%d",&n);
// for(i=0;i<n;i++)
// scanf("%d",&arr[i]);
// scanf("%d",&m);
// for(i=0;i<n;i++)
// {
// if(m<arr[i])
// count++;
// }
// printf("%d",count);
// return 0;
//}
//#include<cstdio>
//#pragma warning(disable:4996)
////#define LOCAL
//void main()
//{
//#ifdef LOCAl
// freopen("in.txt","r",stdin);
// freopen("out.txt","w",stdout);
//#endif
// int n,m,i,j=0;
// scanf("%d",&n);
// int a[100];
// for(i=0;i<n;i++)
// scanf("%d",&a[i]);
// scanf("%d",&m);
// for(i=0;i<n;i++)
// {
// if(a[i]<m)
// j++;
// }
// printf("%d\n",j);
//}
// 调和级数
//#include<stdio.h>
//int main()
//{
//
// // printf("%.3lf",1+double(1)/2+double(1)/3);
// double sum=0;
// int n;
// scanf("%d",&n);
// for(int i=1;i<=n;i++)
// {
// /* double start =1;
// start=start/i;*/
// sum += double(1)/i;
// }
// printf("%.3lf",sum);
// return 0;
//}
// 近似计算 求π的值
//#include<stdio.h>
//int main()
//{
//
// double num = 0.00000;
// int i;
// for( i=1;double(1)/i - double(1)/(i+2)>=1/1000000;i=i+4)
// {
// num += double(1)/i - double(1)/(i+2);
// printf("π的值为: %lf.29\n",4*num);
// }
// printf("π的值为: %.29lf",4*num);
// return 0;
//}
//
// 近似计算 正确版
//#include<stdio.h>
//int main(void)
//{
//
// double num = 0;
// int flag = 1;
// int i;
// for(i=1; 1.0/i >= 0.000001; i+=2)
// {
// num += (1.0/i * flag);
// flag *= -1;
// }
// printf("π的值为: %.lf",4*num);
// return 0;
//}
//
//#include<stdio.h>
//int main()
//{
// int flag=1;
// double num = 0;
// int i;
// for(i=1; 1.0/i >= 0.000001; i+=2)
// {
// num += (1.0/i*flag);
//
// flag *= -1;
// }
// printf("%lf",4*num);
// return 0;
//}
//#include<stdio.h>
//int main()
//{
// int m,n,i;
// double sum=0;
// scanf("%d %d",&n,&m);
// if(n>m || m>1000000)
// return -1;
// for(i=n;i<=m;i++)
// {
// sum+=1.0/((long long )i*i);
// }
// printf("%.5lf",sum);
// return 0;
//}
/// 不考虑四舍五入的情况
//#include<stdio.h>
//int main()
//{
// int a,b,c;
// int count = 1;
// scanf("%d %d %d",&a,&b,&c);
// if(a>1000000 || b>1000000 || c>100)
// return -1;
// printf("%d.",a/b);
// while(count<=c)
// {
// a=a%b*10;
// printf("%d",a/b);
// count++;
// }
// return 0;
//}
// 带四舍五入的版本
//#include<stdio.h>
//int main()
//{
// int a,b,c,count=1,x;
// scanf("%d %d %d",&a,&b,&c);
// printf("%d.",a/b);
// a=a%b*10;
// while(count<=c)
// {
// x=a/b;
// if(count==c)
// printf("%d",(a%b*10)/b>=5?x+1:x);
// else
// printf("%d",x);
// a=a%b*10;
// count++;
// }
// return 0;
//}
// permutation
//#include<stdio.h>
//int main()
//{
// int a,b,c,d,e,f,g,h,i;
// for(a=1;a<=3;a++)
// for(b=1;b<=9;b++)
// if(a!=b)
// for(c=1;c<=9;c++)
// if(a!=c && b!=c)
// for(d=2*a;d<=6;d++)
// if(a!=d && b!=d && c!=d )
// for(e=1;e<=9;e++)
// if(a!=e && b!=e && c!=e && d!=e)
// for(f=1;f<=9;f++)
// if(a!=f && b!=f && c!=f && d!=f && e!=f)
// for(g=3*a;g<=9;g++)
// if(a!=g && b!=g && c!=g && d!=g && e!=g && f!=g )
// for(h=1;h<=9;h++)
// if(a!=h && b!=h && c!=h && d!=h && e!=h && f!=h && g!= h)
// for(i=1;i<=9;i++)
// if(i!=a && i!=b && i!=c && i!=d && i!=e && i!=f && i!=g && i!=h)
// if((d*100+e*10+f)==2*(a*100+b*10+c) && (g*100+h*10+i)==3*(a*100+b*10+c))
// { printf("%d\n",a*100+b*10+c);printf("%d\n",d*100+e*10+f);printf("%d\n",g*100+h*10+i);printf("\n\n");}
//
//
// return 0;
//}
// 逆序输出
//#include<stdio.h>
//#define MAX 100 + 10
//int main()
//{
// int arr[MAX];
// int i,x, n=0;
// while(scanf("%d",&x)==1)
// arr[n++] = x;
// for(i=n-1;i>=0;i--)
// printf("%d",arr[i]);
// printf("\n");
// printf("%d",arr[0]);
// return 0;
//}
// 开灯问题
//#include<stdio.h>
//#include<string.h>
//#define MAX 1000 + 10
//int main()
//{
// int arr[MAX];
// int i,j,n,k,first = 1;
// memset(arr,0,sizeof(arr));
// scanf("%d %d",&n,&k);
// for(i=1;i<=k;i++)
// for(j=1;j<=n;j++)
// if(j%i==0) arr[j] =! arr[j];
//
// for(i=1;i<=n;i++)
// if(arr[i])
// {
// if(first) {first = 0;printf("%d",arr[i]);}
// else
// {
// printf(" "); printf("%d",i);
// }
// }
// printf("\n");
//
//
// return 0;
//}
//#include<stdio.h>
//int main()
//{
// int arr[10];
// arr[0]=0;
// arr[0] = !arr[0];
// printf("%d",arr[0]);
// return 0;
//}
//#include<stdio.h>
//int main()
//{
// printf("%d",2%4);
// return 0;
//
//}
//#include<iostream>
//using namespace std;
// void SwapInt(int *p,int *q)
// {
//
// int temp = *p;
// *p = *q;
// *q = temp;
// }
//int main()
//{
// int a=3;
// int b=5;
// SwapInt(&a,&b);
// cout << a << " " << b << endl;
// return 0;
//}
//#include<iostream>
//using namespace std;
//int main()
//{
// int a=100;
// while(a<=999)
// {
// if((a/100)*(a/100)*(a/100)+(a/10%10)*(a/10%10)*(a/10%10)+(a%10)*(a%10)*(a%10)==a)
// cout << a << endl;
// a++;
// }
// return 0;
//}
//#include<iostream>
//using namespace std;
//int main()
//{
// for(int a=1000;a<10000;a++)
// {
// if((a/1000==a%10) && (a/100%10==a/10%10))
// cout << a << endl;
// }
// return 0;
//
//}
//
//#include<iostream>
//using namespace std;
//int main()
//{
// int m;
// cin >> m;
// for(int n=10000;n<100000;n++)
// {
// int a = n/10000;
// int b = n/1000%10;
// int c = n/100%10;
// int d = n/10%10;
// int e = n%10;
// if ((a==e) &&(b==d))
// {
// if(a+b+c+d+e==m)
// cout << n << endl;
// }
// }
// for(int b=100000;b<1000000;b++)
// {
// int q=b/100000;
// int w=b/10000%10;
// int e=b/1000%10;
// int r=b/100%10;
// int t=b/10%10;
// int y=b%10;
// if((q==y) && (w==t) && (e==r) )
// if(q+w+e+r+t+y == m)
// cout << b << endl;
// }
// return 0;
//
//#include <iostream>
//#include <stdio.h>
//#include <list>
//using namespace std;
//char p[2];
////char Exchange(int number)
////功能:将输入的数字转为对应的十六进制字符
//char Exchange(int number)
//{
// if(number < 10)
// {
// sprintf(p,"%d",number);//将int型数据写入p字符串中
// return p[0];
// }
// else
// {
// switch(number)
// {
// case 10:return 'A';
// case 11:return 'B';
// case 12:return 'C';
// case 13:return 'D';
// case 14:return 'E';
// case 15:return 'F';
// }
// }
//}
//int main()
//{
// list<char>exp;
// unsigned int num;//记录待转化的数
// //unsigned int 0 ~ 4294967295
// cin>>num;
// if(num == 0)//输入为0的情况
// {
// cout<<num<<endl;
// }
// else//输入大于0的情况
// {
// int re;//记录余值
// while(num > 0)
// {
// re = num%16;
// exp.push_front(Exchange(re));
// num /= 16;
// }
// int size = exp.size();
// while(size--)//输出
// {
// cout<<exp.front();
// exp.pop_front();
// }
// }
// return 0;
//}
//
//#include<iostream>
//#include<string.h>
//using namespace std;
//char str[10];
//char Ex(int num)
//{
// if(num<10)
// return num + '0';
// else
// return num - 10 + 'A';
//}
//int main()
//{
// unsigned int num;
// cin >> num;
// int i=0;
// while(num>0)
// {
// char re = num % 16;
// str[i++] = Ex(re);
// num /= 16;
// }
// int len = strlen(str)-1;
// for(;len>=0;len--)
// cout << str[len] ;
// return 0;
//}
//#include<iostream>
//#include<math.h>
//#include<string.h>
//using namespace std;
//
//
//int main()
//{
// long long num=0;
// char str[8];
// cin >> str ;
// int re;
// int len = strlen(str);
// for (int i=0;i<len;i++)
// {
// if(str[i]>='A')
// num += (str[i]-'A'+10) * pow(16,len-1-i);
// else
// num += (str[i]-'0')*pow(16,len-1-i);
// }
// cout << num << endl;
// return 0;
//}
//#include<iostream>
//using namespace std;
//int main()
//{
// char hex_num[9];
// cin >> hex_num;
// int l; // 十六进制数长度
// long long dnum = 0;
// for(l=0;hex_num[l]!='\0';l++); // 这个6啊 你他么的 用strlen()不就行了吗
// cout << l << endl;
//
// for(int i=l-1;i>=0;i--){ // 位权展开法
// int num;
// long long weight = l; // 权值
// if('0'<=hex_num[i] && hex_num[i]<='9')
// num = hex_num[i] - '0';
// else if ('A'<=hex_num[i] && hex_num[i]<='F')
// num = hex_num[i] - 'A' + 10;
// for(int j=l-1;j>1;j--)
// weight*=16;
//
// dnum+=num*weight;
// cout << dnum << endl;
// }
// cout << dnum << endl;
// return 0;
//}
//#include<iostream>
//#include<cmath>
//#include<string>
//using namespace std;
//int main()
//{
// string hex;
// long long dec = 0;
// cin>>hex;
// int len = hex.length();
// for(int i=0 ;i<len;i++)
// {
// if(hex[i] >= 'A')
// {
// dec += (hex[i] - 'A' + 10)*pow(16,len-1-i);
// }
// else
// {
// dec += (hex[i] - '0')*pow(16,len-1-i);
// }
// }
// cout<<dec;
// return 0;
//}
//#include<iostream>
//#include<math.h>
//#include<string.h>
//using namespace std;
//
//int Ex(char s)
//{
// if(s>='0' && s<='9')
// return s - '0';
// else if(s>='A' && s<='F')
// return s - 'A' + 10;
//}
//int main()
//{
// long long num=0;
// char str[8];
// cin >> str ;
// int re;
// int len = strlen(str)-1;
// for(int i=len;i>=0;i--)
// {
// re = Ex(str[i]);
//
// num += pow(16,len-i) * re;
//
// }
// cout << num << endl;
// return 0;
//}
//#include<iostream>
//#include<string>
//using namespace std;
//
//int main()
//{
// int n;
// cin >> n;
//
// return 0;
//}
//#include <iostream>
//#include <string>
//#include <cmath>
//using namespace std;
//int arr[10000001]; // 记录八进制的数
//
//int main()
//{
// string str;
// int n,m,i,num,j;
//
// cin>>n;
// while(n--)
// {
// cin>>str;
// m=str.length();
// // 转换成十进制
// num=0;
// for(i=m-1;i>=0;--i)
// {
// if(str[i]>='0'&&str[i]<='9')
// num+=pow(16,m-1-i)*(str[i]-'0');
// else if(str[i]>='A'&&str[i]<='F')
// num+=pow(16,m-1-i)*(str[i]-'A'+10);
// }
//
// i=0;
// while(num/8!=0)
// {
// arr[i]=num%8;
// num/=8;
// ++i;
// }
// arr[i]=num;
//
// for(j=i;j>=0;--j)
// cout<<arr[j];
// cout<<endl;
//
// }
// return 0;
//}
// 十六进制转换八进制
//#include <iostream>
//#include <string>
//using namespace std;
//int arr[10000001];
//
//int main()
//{
// int n,len_str,i,j;
// string str,str2;
// cin>>n;
// while(n--)
// {
// cin>>str;
// len_str=str.length();
// str2="";
//
// // 十六进制转换为二进制
// for(i=0;i<len_str;++i)
// {
// switch(str[i])
// {
// case '0':str2+="0000";break;
// case '1':str2+="0001";break;
// case '2':str2+="0010";break;
// case '3':str2+="0011";break;
// case '4':str2+="0100";break;
// case '5':str2+="0101";break;
// case '6':str2+="0110";break;
// case '7':str2+="0111";break;
// case '8':str2+="1000";break;
// case '9':str2+="1001";break;
// case 'A':str2+="1010";break;
// case 'B':str2+="1011";break;
// case 'C':str2+="1100";break;
// case 'D':str2+="1101";break;
// case 'E':str2+="1110";break;
// case 'F':str2+="1111";break;
// default:break;
// }
// }
//
// // 修正位数
// if(len_str%3==1) str2="00"+str2;
//
// else if(len_str%3==2) str2="0"+str2;
//
//
// len_str=str2.length();
// // 二进制转换八进制
// j=0;
// for(i=0;i<len_str-2;i+=3)
// {
// arr[j]=(str2[i]-'0')*4+(str2[i+1]-'0')*2+(str2[i+2]-'0');
// ++j;
// }
//
// for(i=0;i<j;++i)
// {
// if(i==0 && arr[i]==0) continue;
// cout<<arr[i];
// }
// cout<<endl;
//
// }
// return 0;
//}
//
//#include<iostream>
//using namespace std;
//int num[100];
//int main()
//{
// int len;
// cin >> len;
// if(len>200 || len<0) return 0;
// for (int i=0;i<len;i++)
// {
// cin >> num[i];
// }
// for(int m=0;m<len;m++)
// {
// for(int n=0;n<len-m-1;n++)
// {
// if(num[n]>num[n+1])
// {
// int temp = num[n];
// num[n] = num[n+1];
// num[n+1] = temp;
// }
// }
// }
// for(int j=0;j<len;j++)
// cout << num[j] << " " ;
// return 0;
//}
//#include<iostream>
//#include<algorithm>
//using namespace std;
//int num[1001];
//int main()
//{
// int n,m,l,r,k;
// cin >> n;
// for(int i=1;i<n;i++)
// cin >> num[i];
// cin >> m;
// while(m--)
// {
// cin >> l >> r >> k;
// int j=0;
// int b[1001];
// int len = r-l+1;
// for(int i=l;i<=r;i++)
// b[j++] = num[i];
// sort(b,b+len);
// cout << b[len-k] << endl;
// }
// return 0;
//}
//
//
//// 这是标准的
//
//#include<cstdio>
//#include<cstring>
//#include<iostream>
//#include<algorithm>
//using namespace std;
//int main()
//{
// int n,m,a[1001],k,l,r;
// //scanf("%d",&n);
// cin >> n;
// for(int i=1;i<=n;i++)
// //scanf("%d",&a[i]);
// cin >> a[i];
// //scanf("%d",&m);
// cin >> m;
// while(m--){
// //scanf("%d%d%d",&l,&r,&k);
// cin >> l >> r >> k;
// int b[1001];
// int j=0,len=r-l+1;
// for(int i=l;i<=r;i++){
// b[j++]=a[i];
// }
// sort(b,b+len);
// //printf("%d\n",b[len-k]);
// cout << b[len-k] << endl;
// }
// return 0;
//}
//#include<iostream>
//using namespace std;
//int main()
//{
// long long n,ans;
// cin >> n;
// if(n<=2)
// ans = n;
// else if(n%2==1)
// ans = n*(n-1)*(n-2);
// else
// {
// if(n%3==0)
// ans = (n-1)*(n-2)*(n-3);
// else
// ans = n*(n-1)*(n-3);<
以前写的破代码,不忍心扔
最新推荐文章于 2019-03-03 17:22:00 发布
本文探讨了面对旧代码时的困境,如何分析其问题,并通过重构提升代码质量和可维护性,实现软件工程的持续改进。
摘要由CSDN通过智能技术生成