摘要: PTA 1 #include <stdio.h> 2 int main(){ 3 //无符号整型才能表达32位二进制数对应的十进制数 4 unsigned int decimalNum; 5 unsigned int digitsCount=0; 6 scanf("%u", &decimalNum) 阅读全文
posted @ 2019-04-23 19:18 cxc1357 阅读(198) 评论(0) 推荐(0)
摘要: PTA 7-46 爬动的蠕虫 1 #include<stdio.h> 2 int main() { 3 int N,U,D,R,T=0; 4 scanf("%d%d%d",&N,&U,&D); 5 R = N-U; 6 if(R<=0) T=1; 7 else { 8 T = R/(U-D)*2+1 阅读全文
posted @ 2019-04-23 18:56 cxc1357 阅读(247) 评论(0) 推荐(0)
摘要: PTA 7-45 找完数 网友“云上明月”的程序: 1 #include<stdio.h> 2 int isPerfect(int num); 3 4 int main() { 5 int i,j,m,n,exist=0; 6 int maxFactor; 7 scanf("%d%d",&m,&n) 阅读全文
posted @ 2019-04-23 10:52 cxc1357 阅读(758) 评论(0) 推荐(0)
摘要: 我的程序,一个用例通不过 1 #include<stdio.h> 2 void sort(int *a,int n); 3 4 int main() { 5 int num,a,b,c,count=1; 6 scanf("%d",&num); 7 while(num!=495&&num!=0) { 阅读全文
posted @ 2019-04-23 09:46 cxc1357 阅读(469) 评论(0) 推荐(0)
摘要: 思路: 1、输入:数组长度n,待查找的有序数组a[],要找的元素key 2、输出:待查找元素在数组中的位置,若不存在返回-1 3、实现:三个指针,left、mid、right 1 #include<stdio.h> 2 int binarySearch(int a[],int key,int n); 阅读全文
posted @ 2019-04-22 22:42 cxc1357 阅读(191) 评论(0) 推荐(0)
摘要: 程序: 1 #include<stdio.h> 2 int main() { 3 int i,n,*result; 4 scanf("%d",&n); 5 int shuffle[54],card1[54],card2[54]; 6 result = n%2==0?card1:card2; 7 fo 阅读全文
posted @ 2019-04-22 15:59 cxc1357 阅读(241) 评论(0) 推荐(0)
摘要: 模拟除法 1 #include <stdio.h> 2 int main() 3 { 4 char a[1000];//创建存表 5 int len=0,count=0; 6 int n; 7 int t=1; 8 scanf("%d",&n); 9 while(1) 10 { 11 count++ 阅读全文
posted @ 2019-04-18 16:24 cxc1357 阅读(242) 评论(0) 推荐(0)
摘要: 程序: 1 #include<stdio.h> 2 #include<math.h> 3 int main() { 4 int i=0,N; 5 scanf("%d",&N); 6 int H[N],W[N]; 7 double P; 8 for(i=0; i<N; i++) { 9 scanf(" 阅读全文
posted @ 2019-04-18 14:26 cxc1357 阅读(1449) 评论(0) 推荐(0)
摘要: 程序: 1 #include <stdio.h> 2 3 int main () { 4 5 int rabbit=0,turtle=0,minute,rest=-1,run=10; //rest为0或负时,兔子休息,run为1-10是兔子跑 6 scanf ("%d",&minute) ; 7 8 阅读全文
posted @ 2019-04-18 13:44 cxc1357 阅读(632) 评论(0) 推荐(0)
摘要: 程序: 1 #include<stdio.h> 2 3 int main() { 4 int n,f,y; 5 int flag = 0; 6 scanf("%d",&n); 7 for(y=0; flag==0 && y<=50; y++) { 8 for(f=0; f<=100; f++) { 阅读全文
posted @ 2019-04-18 10:33 cxc1357 阅读(348) 评论(0) 推荐(0)