随笔分类 - C
摘要:1 #include <stdio.h> 2 #include <math.h> 3 4 int main() 5 { 6 long int sum; 7 long int a,b; 8 int ka = 0,kb,i,j; 9 printf("Enter sum:\n");10 scanf("%ld",&sum);11 for(a = 100; a <= sum; a++)12 {13 b = sum -a;14 if(b < 100)15 {16 return...
阅读全文
摘要:1 #include <stdio.h> 2 3 int main() 4 { 5 //实现幂函数 6 double power(double x, double y); 7 8 printf("%f\n", power(2.0, 3.0)); 9 10 //开跟号11 double ssqrt(double x);12 printf("%f\n", ssqrt(64.0));13 14 15 //统计输入的数字、空白符(空格、制表符、回车符)以及所有其他字符出现的次数 16 // F6 或...
阅读全文
摘要:#include <stdio.h>#include <stdlib.h>#include <iostream.h>#include <time.h> #define Bsize 3#define Psize 20struct pageInfor{ int content;//页面号 int timer;//被访问标记};class LRU{ public: LRU(int qstring[]); int findSpace(void);//查找是否有空闲内存 int findExist(int curpage);//查找内存中是否有该页面 in
阅读全文
摘要:结果图 1 #include <stdio.h> 2 //s为初态,z为终态 3 int in(int s,int z) 4 { 5 if(s == z) 6 { 7 printf("3\nlook!the last status belongs to Z"); 8 return 1; 9 }10 else11 {12 return 0;13 }14 }15 //s为状态,t为输入的字符16 int step(int s,char t)17 {18 if(t == 'a')19 ...
阅读全文
摘要:1 #include <stdio.h> 2 int main() 3 { 4 int a ,b,c; 5 printf("请输入第一个数字"); 6 scanf("%d",&a); 7 printf("请输入第二个数字"); 8 scanf("%d",&b); 9 printf("交换之前a=%d\tb=%d",a,b);10 printf("\n");11 a = a + b;12 b = a - b;13 a = a - b;14 print
阅读全文
摘要:1 #include <stdio.h> 2 3 int main() 4 { 5 int c,m,n,l; 6 m=n=l=0; 7 /* m代表空格个数,n代表制表符个数,l代表换行符个数 */ 8 int flag=0;//表示是否遇到换行符 9 while((c = getchar()) != EOF)10 {11 if(c == '\n')12 {13 ++l;14 flag = 1;15 continue;16 ...
阅读全文
摘要:1 #include <stdio.h> 2 3 int main() 4 { 5 int c = 0,flag = 0; 6 printf("Clear blanks"); 7 while((c=getchar()) != EOF) 8 { 9 if(c == ' ')10 {11 if(flag == 0)12 {13 flag = 1;14 }15 else16 {17 ...
阅读全文

浙公网安备 33010602011771号