zrq495
www.zrq495.com
摘要: 大数的第一道题,比较简单,仔细一点就行了。代码如下: 1 #include<stdio.h> 2 #include<string.h> 3 4 int main() 5 { 6 int i, s[10000], sum[10000]={0}, n, j, k, flag; 7 char a[10000]; 8 gets(a); 9 while(a[0] != '0')10 {11 n=strlen(a);12 memset(s,0,sizeof(s));13 for (i=0; i<n;i++)14 ... 阅读全文
posted @ 2012-06-03 15:46 zrq495 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 挺简单的,直接上代码。 1 #include<stdio.h> 2 #include<string.h> 3 4 char str[100][100]; 5 6 int comp(int x, int y) 7 { 8 int n, m, i; 9 n=strlen(str[x]);10 m=strlen(str[y]);11 if (n>m)12 n=m;13 for (i=0; i<n; i++)14 {15 if (str[x][i] != str[y][i])16 return 1;17... 阅读全文
posted @ 2012-06-02 23:08 zrq495 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 第一次RE,数组定义的太小了,题目说是5000个单词,如果加上重复的就不够了。第二次TLE,我用的是选择排序,应该用快排。快排函数:用 法: void qsort(void *base, int nelem, int width, int (*fcmp)(const void *,const void *)); 参数:1 待排序数组首地址 2 数组中待排序元素数量 3 各元素的占用空间大小 4 指向函数的指针,用于确定排序的顺序 qsort 的函数原型是void __cdecl qsort ( void *base, size_t num, size_t width, int (__... 阅读全文
posted @ 2012-05-31 20:47 zrq495 阅读(216) 评论(0) 推荐(0) 编辑
摘要: 开始的时候没看懂,然后看到空格和o时就想到了——很久很久以前输入指令要:打孔。然后就简单了。。。这也是我在UVa上见到的题目最短的题了。。。代码如下: 1 #include<stdio.h> 2 #include<string.h> 3 int a[11]={0, 128,64,32,16,8,0,4,2,1}; 4 int main() 5 { 6 int i, n, b; 7 char str[20]; 8 while(gets(str)) 9 {10 if (str[0] != '|')11 continue;12 ... 阅读全文
posted @ 2012-05-31 18:26 zrq495 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 1A,呵呵。注意不区分大小写,如果单词重复也要算的,还有单词要合法,就是哲句话“A keyword ``occurs" in an excuse if and only if it exists in the string in contiguous form and is delimited by the beginning or end of the line or any non-alphabetic character or a space.”代码如下: 1 #include<stdio.h> 2 #include<string.h> 3 4 char 阅读全文
posted @ 2012-05-31 17:17 zrq495 阅读(339) 评论(0) 推荐(0) 编辑
摘要: 题很简单,但是由于粗心,导致各种纠结,WA了N多次。。。。。AC代码如下: 1 #include<stdio.h> 2 #include<string.h> 3 4 void func(char str[]) 5 { 6 int len, i, j, con, dot, n; 7 double value[100], sum; 8 char s[100]; 9 len=strlen(str);10 memset(value, 0, sizeof(value));11 for (i=0; i<len; i++)12 {13 ... 阅读全文
posted @ 2012-05-31 15:58 zrq495 阅读(195) 评论(0) 推荐(0) 编辑
摘要: 题目描述: There is one Master In ACM_DIY called "白衣少年"(White) whose motto is "I can HOLD ANY FEMALE". Since White is really busy with HOLDING FEMALES, he has no idea of the work that is given by his boss(MALE, of course), so can you help him to solve such a simple and really easy pro 阅读全文
posted @ 2012-05-26 20:44 zrq495 阅读(275) 评论(0) 推荐(0) 编辑
摘要: 众里寻他千百度! --------转载请注明:转载自奶牛博客 自从ubuntu 9.10开始,ubuntu正式开始使用grub2作为引导程序。对于多系统用户,可能有时候会将引导搞丢了(比如双系统下重新安装windows系统等),下面奶牛来介绍下ubuntu等linux系统的grub2的修复。 1.需要一张可以引导的ubuntu live-cd,并且版本在9.10+用live-cd引导进入系统,然后在mnt目录下挂载分区。首先我们需要确定一个问题,你的/boot是否单独分区了,如果单独分区了请按照方法A进行,如果/boot没有单独分区,可以按照B来进行。A:以/boot为sda8,/为sda9为 阅读全文
posted @ 2012-05-26 18:57 zrq495 阅读(1469) 评论(0) 推荐(0) 编辑
摘要: emacs初体验,真不习惯。那个缩进竟然是两个空格,还有每次换行都要按Tab键。。。感觉代码看起来很乱。。。只是知道那么一点点,还是继续练吧。题目很简单,水题。AC代码如下: 1 #include<stdio.h> 2 #include<string.h> 3 4 int main() 5 { 6 int i, t1, t2, t3, T, t4, n, m; 7 char s1[105], s2[105]; 8 scanf("%d%*c", &T); 9 while(T--){10 gets(s1);11 gets(s2);12 n=str 阅读全文
posted @ 2012-05-25 21:29 zrq495 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 题意很好理解,从八个方向查找字符串。真麻烦。。。不过1A 。^_^在输入的时候把大写字母全都转换 成小写字母,这样省事。在判断的时候我下面的8次代码判断,其实向左和向右用一个函数就可以判断,写四个函数就可以了。。。代码有点长。。。如下: 1 #include<stdio.h> 2 #include<string.h> 3 4 int m, n; 5 char str[55][55], s[55]; 6 7 void strlwr(char str[]) //大写字母变小写字母 8 { 9 int i=0; 10 while(s... 阅读全文
posted @ 2012-05-25 20:16 zrq495 阅读(259) 评论(0) 推荐(0) 编辑
摘要: 题意很难懂,读了很长时间。。。AC代码: 1 #include<stdio.h> 2 #include<string.h> 3 4 int main() 5 { 6 int n, i, j, dna[10], a[42], t, p; 7 scanf("%d", &n); 8 while(n--) 9 {10 for (i=0; i<10; i++)11 {12 scanf("%d", &dna[i]);13 }14 memset(a, 0, sizeof(a));15 ... 阅读全文
posted @ 2012-05-24 18:04 zrq495 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 这题是相当的纠结啊,WA了10+次。。。AC代码: 1 #include<stdio.h> 2 #include<string.h> 3 4 char one[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"; 5 char two[]="A 3 HIL JM O 2TUVWXY51SE Z 8 "; 6 7 int palin(char str[]) 8 { 9 int i, j;10 j=strlen(str)-1;11 for (i=0; i<=j; i++, j--)12 {13 if( 阅读全文
posted @ 2012-05-24 16:48 zrq495 阅读(357) 评论(0) 推荐(0) 编辑
摘要: 把输入的字符顺时针旋转90度。 1 #include<stdio.h> 2 #include<string.h> 3 4 int main() 5 { 6 int i, j, max, n, m; 7 char s[105][105]; 8 max=0; 9 memset(s, '\0', sizeof(s));10 for (i=0; gets(s[i]); i++)11 {12 n=strlen(s[i]);13 if (max < n)14 {15 max=n;16 ... 阅读全文
posted @ 2012-05-22 19:51 zrq495 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 和3n+1类似,注意要用long long,int会TLE。代码如下: 1 #include<stdio.h> 2 int main() 3 { 4 long long n, m, term, i, num=1; 5 scanf("%lld%lld", &n, &m); 6 while(n>=0 || m>=0) 7 { 8 term=1; 9 i=n;10 while(i<=m && i!=1)11 {12 if (i%2 == 0)13 {14 ... 阅读全文
posted @ 2012-05-22 16:48 zrq495 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 把题读明白就行了,水题。注意判断之后及时的退出循环。 1 #include<stdio.h> 2 #include<string.h> 3 4 int main() 5 { 6 int T, hangman=7, n, m, i, j, error, flag, right; 7 char s1[1000], s2[1000]; 8 while(scanf("%d%*c", &T)==1 && T!=-1) 9 {10 gets(s1);11 gets(s2);12 n=strlen(s1);13 ... 阅读全文
posted @ 2012-05-22 16:10 zrq495 阅读(197) 评论(0) 推荐(0) 编辑