
C
文章平均质量分 70
SeeBro
这个作者很懒,什么都没留下…
展开
-
孪生素数
#include #include #include int is_prime(int x){ int i, m; assert(x >= 0); if (x == 1) { return 0; } m = floor(sqrt(x)原创 2011-09-07 21:25:39 · 355 阅读 · 0 评论 -
uva488 Triangle Wave
Triangle Wave In this problem you are to generate a triangular wave form according to a specified pair of Amplitude and Frequency.Input and OutputThe input begins with a single positive原创 2011-11-28 17:24:15 · 756 阅读 · 0 评论 -
uva445 Marvelous Mazes
Marvelous Mazes Your mission, if you decide to accept it, is to create a maze drawing program. A maze will consist of the alphabetic characters A-Z, * (asterisk), and spaces.Input and原创 2011-11-28 01:03:06 · 1718 阅读 · 2 评论 -
uva 10071 Back to High School Physics
Back to High School PhysicsInput: standard inputOutput: standard output A particle has initial velocity and constant acceleration. If its velocity after certain time is v then what will its di原创 2011-11-20 22:16:46 · 766 阅读 · 0 评论 -
uva489 Hangman Judge
Hangman Judge In ``Hangman Judge,'' you are to write a program that judges a series of Hangman games. For each game, the answer to the puzzle is given as well as the guesses. Rules are the原创 2011-11-30 00:47:24 · 2929 阅读 · 2 评论 -
uva694 The Collatz Sequence
The Collatz Sequence An algorithm given by Lothar Collatz produces sequences of integers, and is described as follows:Step 1:Choose an arbitrary positive integer A as the first item in t原创 2011-11-30 22:55:11 · 1101 阅读 · 0 评论 -
uva457 Linear Cellular Automata
Linear Cellular Automata A biologist is experimenting with DNA modification of bacterial colonies being grown in a linear array of culture dishes. By changing the DNA, he is able ``program" th原创 2011-12-03 01:08:30 · 1900 阅读 · 1 评论 -
预编译
(1) 宏定义1.不带参数的宏定义用一个宏名代替一个字符串,只进行简单的代换,不进行任何计算,也不进行正确性检查,双引号内的宏名不进行代换,宏名一般用大写表示。#define PI 3.1415926#define定义有效范围是定义处到源文件结束,通常写在文件开头,函数前,在此文件内有效。#define PI 3.1415926int main(){原创 2011-12-19 19:58:30 · 489 阅读 · 0 评论 -
二分搜索
int binary(int array[], int n, int k){ int l = -1; int r = n; while (l+1 != r) { int i = (l+r)/2; if (k < array[i]) r = i; if (k = array[i]) return i;原创 2012-01-19 16:13:19 · 396 阅读 · 0 评论 -
两数交换不借助第三变量
#include void swap(int *x, int *y){ *y = *x ^ *y; *x = *x ^ *y; *y = *x ^ *y;}void revert(int *a, int len){ int first = 0, last = len - 1; for (;first < last; first++, last--) swap(&a[fi原创 2012-01-29 14:32:25 · 443 阅读 · 0 评论 -
元素翻转
1.杂技翻转#include int gcd(int i, int j){ while (i != j) if (i > j) i -= j; else j -= i; return i; }int main(){ freopen("datain.txt", "r", stdin); int i, rotdist, n; char x[] = {"12原创 2012-02-28 21:13:09 · 555 阅读 · 0 评论 -
位图排序
输入:一个最多包涵n个正整数的文件 输出:按升序排列输入的整数列表#include #include #define N 100int bit[N], n;int main(){ freopen("datain.txt", "r", stdin); freopen("dataout.txt", "w", stdout); //1.initial set to e原创 2012-02-28 18:55:04 · 430 阅读 · 0 评论 -
uva 458 The Decoder
The Decoder Write a complete program that will correctly decode a set of characters into a valid message. Your program should read a given file of a simple coded set of characters and pr原创 2011-11-23 18:55:57 · 1623 阅读 · 0 评论 -
posix IPC shared_memory一例
#include #include #include int value = 5;int main(void){ pid_t pid; pid = fork(); if (pid == 0) { value += 15; } else if (pid > 0) { wait(NULL); printf("PARENT: value = %d",原创 2011-08-24 23:36:06 · 1070 阅读 · 0 评论 -
uva494 Kindergarten Counting Game
Kindergarten Counting Game Everybody sit down in a circle. Ok. Listen to me carefully.``Woooooo, you scwewy wabbit!''Now, could someone tell me how many words I just said?Input a原创 2011-11-23 20:24:17 · 1820 阅读 · 0 评论 -
Minesweeper
Problem B: Minesweeper The ProblemHave you ever played Minesweeper? It's a cute little game which comes within a certain Operating System which name we can't really remember. Well, t原创 2011-11-03 23:32:22 · 793 阅读 · 0 评论 -
WERTYU
Problem C: WERTYUA common typing error is to place the hands on the keyboard one row to the right of the correct position. So "Q" is typed as "W" and "J" is typed as "K" and so on. You are to de原创 2011-11-14 19:30:57 · 1173 阅读 · 0 评论 -
uva 10300 Ecological Premium
Problem AEcological PremiumInput: standard inputOutput: standard outputTime Limit: 1 secondMemory Limit: 32 MBGerman farmers are given a premium depending on the conditions at their farmya原创 2011-11-21 18:08:21 · 745 阅读 · 0 评论 -
The Trip
Problem A: The TripA number of students are members of a club that travels annually to exotic locations. Their destinations in the past have included Indianapolis, Phoenix, Nashville, Philadelphia,原创 2011-11-04 22:36:07 · 855 阅读 · 0 评论 -
uva 10038 jollyjumper
stack应用#include #include #include #define max 3005using namespace std;int t[max];stack a;void clear(){ while (!a.empty()) a.pop();}int main(){ int n; while (cin >> n原创 2011-11-16 23:30:04 · 585 阅读 · 0 评论 -
uva414 Machined Surfaces
Machined Surfaces An imaging device furnishes digital images of two machined surfaces that eventually will be assembled in contact with each other. The roughness of this final contact is原创 2011-11-24 22:26:52 · 1771 阅读 · 0 评论 -
uva490 Rotating Sentences
Rotating Sentences In ``Rotating Sentences,'' you are asked to rotate a series of input sentences 90 degrees clockwise. So instead of displaying the input sentences from left to right and原创 2011-11-24 23:57:41 · 1979 阅读 · 1 评论 -
uva100 The 3n + 1 problem
The 3n + 1 problem BackgroundProblems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In this problem you will原创 2011-11-02 21:41:26 · 491 阅读 · 0 评论 -
uva706 LC-Display
LC-Display A friend of you has just bought a new computer. Until now, the most powerful computer he ever used has been a pocket calculator. Now, looking at his new computer, he is a bit disappointed,原创 2011-11-08 18:49:29 · 1365 阅读 · 4 评论 -
uva 10055 Hashmat the Brave Warrior
Hashmat the brave warriorInput: standard inputOutput: standard output Hashmat is a brave warrior who with his group of young soldiers moves from one place to another to fight against his o原创 2011-11-20 21:28:18 · 517 阅读 · 0 评论 -
编程珠玑笔记--排序
首先来个插入排序?12345678910111213141516171819202122232425#include stdio.h>原创 2012-04-26 22:49:51 · 706 阅读 · 0 评论