Cover，这个问题用C语言怎么实现的？

Problem Description
The Wall has down and the King in the north has to send his soldiers to sentinel.
The North can be regard as a undirected graph (not necessary to be connected), one soldier can cover one path. Today there's no so many people still breathing in the north, so the King wants to minimize the number of soldiers he sent to cover each edge exactly once. As a master of his, you should tell him how to arrange soldiers.

Input
There might be multiple test cases, no more than 20. You need to read till the end of input.
In the first line, two integers n and m, representing the number of nodes and edges in the graph.
In the following m lines, each contain two integers, representing two ends of an edge.
There are no parallel edges or self loops.
1≤n,m≤100000

Output
For each test case, the first line contains number of needed routes, p.
For the following p lines, an integer x in the beginning, followed by x integers, representing the list of used edges. Every integer should be a positive or negative integer. Its absolute value represents the number of chosen edge (1~n). If it's positive, it shows that this edge should be passed as the direction as the input, otherwise this edge should be passed in the direction different from the input. Edges should be in correct order.

Sample Input
3 3
1 2
1 3
2 3

Sample Output
1
3 1 3 -2

1个回答

*rn * *rn * * *rn * * * *rn * * * * *rn * * * *rn * * *rn * *rn *

/**对于任一整数n，符号函数sign(n)的定义如下：rnrsign(n)=-1（n<0）；sign(n)=0（n=0）；sign(n)nr=1. (n>0)；nrn请编写程序计算该函数对任一输入整数的值。rnrn输入格式:rnrn输入在一行中给出整数n。rnrn输出格式:rnrn在一行中按照格式“sign(n) = 函数值”输出该整数n对应的函数值。rnrn输入样例1:rn10rnrnrn输出样例1:rnsign(10) = 1rnrnrn输入样例2:rn0rnrnrn输出样例2:rnsign(0) = 0rnrnrn输入样例3:rn-98rnrnrn输出样例3:rnsign(-98) = -1rn**/

rn门禁信息系统信息结构1：姓名 证件类型 证件编号 rn出入点 ：南门 北门 东门 西门rn出入类型 ： 进 出rn 事由 ：工作，访问，学习，其他rn 接待人： 个人姓名，部门名称rn注意：信息结构1对应文件info_1,姓名至少两条记录（一进一出）rn基本要求：能录入，删除，修改文件info_1,1． 按姓名、证件编号能查询出入信息，统计平均访问时间（时长/次）2． 按接待次数排序，显示接待人(部门)3． 统计各出入点的出入次数，按出入点显示出（入）人和出入事由4． 按事由类型统计显示姓名，滞留时间，并按时间排序存入单独文件5． 按总滞留时间排序，并显示姓名和证件编号，事由，并排序存入单独文件

C语言 怎么用

Flag=1 函数:0xFC ESI:0x1002DCD6 SHRD EAX,EDX,CL EAX=0x6169BCE0 EDX=0x6169BCE0 ECX=0xFF9C0007 rnFlag=2 函数:0xFC EAX=0xC0C2D379 rn这个指令，用C代码怎么实现.rnrnrn大家帮帮忙。解释的清楚一些。偶笨的哈。。。。

C语言怎么用指针实现栈
[code=C/C++]rn/*rn * stack.crn *rn * Created on: 2011-12-2rn * Author: rootrn */rn#includern#includern#define N 5rn//push pop top empty full clear sizerntypedef int T;rntypedef struct rn T *base;rn T *top;rn int n;rn Stack;rnrnvoid p_stackinit(Stack* p) rn p->base = malloc(sizeof(T)*N);rn p->top=p->base;rnrnrnint p_stackfull(Stack *p) rn return p->n==N-1;rnrnrnint p_stackempty(Stack *p) rn return p->n==0;rnrnrnvoid p_stackpush(Stack* p, T d) rn if(p_stackfull(p))rn printf("stack is full!\n");rn return;rn rn printf("d=%d\n",d);rn *p->top++=d;rn ++p->n;rn printf("%d\t\n",*p->top);rnrnrnvoid p_stackpop(Stack* p) rn if(p_stackempty(p))rn printf("stack is empty~!\n");rn return;rn rn T *q=p->top;rn free(p->top);rn p->top=--q;rn --p->n;rnrnrnT p_stacktop(Stack* p) rn if(p_stackempty(p))rn printf("stack is empty~!\n");rn return -1;rn rn return *(p->top);rnrnrnvoid p_stackclear(Stack *p) rn T *q=p->top;rn while(p->n!=0)rn free(p->top);rn p->top=--q;rn --p->n;rn rnrnrnT p_stacksize(Stack *p) rn return p->n;rnrnrnint main() rn Stack s1;rn p_stackinit(&s1);rn printf("test1\n");rn int i;rn for (i = 0; i < N; ++i) rn p_stackpush(&s1, i * 5);rn printf("test2\n");rn rn printf("size=%d\n", p_stacksize(&s1));rn printf("size=%d\n", p_stacksize(&s1));rn while (!p_stackempty(&s1)) rn T t = p_stacktop(&s1);rn printf("%d ", t);rn p_stackpop(&s1);rn rn printf("\n");rn p_stackpop(&s1);rnrn return 0;rnrn[/code]rn不知道错哪儿了，求大家指教（或者给一个参考的例子也行），谢谢了！

【C语言 】用C语言实现乘法口诀表

/**已知某位学生的数学、英语和计算机课程的成绩分别是87分、72分和93分，求该生3门课程的平均成绩。rnrn输入格式：rnrn本题无输入rnrn输出格式：rnrn按照下列格式输出结果：rnmath = 87, eng = 72, comp = 93, average = 计算所得的平均成绩rn**/

Problem DescriptionrnThe ninja Ryu has infiltrated the Shadow Clan fortress and finds himself in a long hallway. Although ninjas are excellent fighters, they primarily rely on stealth to complete their missions. However, many lights are turned on in the hallway, and this way it will not take long before Ryu is spotted by a guard. To remain unseen, Ryu will need to turn off all the lights as quickly as possible.rnThe hallway contains a sequence of n lights L1......Ln. Some of these lights are turned on. Destroy-ing the lights with his shurikens would be too loud, so he needs to turn them off the old-fashioned way, using light switches. Luckily, there is a switch box nearby with a light switch Si for every light Li. However, after trying one of the switches, he notices something funny. When he rnips the switch Si, it does not only turn on/off light Li, but also some of the neighboring lights. Ryu notices that there is a parameter D such that rnipping switch Si turns on/off all the lights L(i-D)......L(i+D), if they exist(This means that S1 turns on/off all the lights L1 ......L(D+1) and Sn turns on/off all the lights L(n-D)......Ln. Of course, if D>=n, then L(D+1) and L(n-D) will not exist either.). Turning on or off lights can attract the attention of the guards, so Ryu would like to turn off all the lights with the minimum number of times rnipping a switch. Can you help him out?rn rnrnInputrnThe first line of the input contains a single number: the number of test cases to follow. Each test case has the following format:rn1.One line with two integers n (1 <= n <= 100) and D (0 <= D <= 15): the number of lights and the parameter mentioned above.rn2.One line with n integers. The i(th) integer describes the current state of light Li, where 0 means off and 1 means on.rn rnrnOutputrnFor every test case in the input, the output should contain one integer on a single line: the minimum number of times Ryu needs to flip a switch to turn off all the lights. If it is impossible to turn off all the lights, then output the string "impossible" instead.rnIn the first example below,flipping switch S4 followed by S7 will turn off all the lights.rn rnrnSample Inputrn2rn7 3rn1 1 1 0 0 0 0rn5 1rn1 0 1 0 1rn rnrnSample Outputrn2rn3

Problem DescriptionrnThere are N cities in the country. Each city is represent by a matrix size of M*M. If city A, B and C satisfy that A*B = C, we say that there is a road from A to C with distance 1 (but that does not means there is a road from C to A).rnNow the king of the country wants to ask me some problems, in the format:rnIs there is a road from city X to Y?rnI have to answer the questions quickly, can you help me?rn rnrnInputrnEach test case contains a single integer N, M, indicating the number of cities in the country and the size of each city. The next following N blocks each block stands for a matrix size of M*M. Then a integer K means the number of questions the king will ask, the following K lines each contains two integers X, Y(1-based).The input is terminated by a set starting with N = M = 0. All integers are in the range [0, 80].rn rnrnOutputrnFor each test case, you should output one line for each question the king asked, if there is a road from city X to Y? Output the shortest distance from X to Y. If not, output "Sorry".rn rnrnSample Inputrn3 2rn1 1rn2 2rn1 1rn1 1rn2 2rn4 4rn1rn1 3rn3 2rn1 1rn2 2rn1 1rn1 1rn2 2rn4 3rn1rn1 3rn0 0rn rnrnSample Outputrn1rnSorry

if object_id('tree') is not null drop table treernrncreate table tree(id varchar(10),code varchar(10),name varchar(20),pid varchar(10))rninsert into tree values ('1','01','A学校',null)rninsert into tree values ('2','0101','计算机学院','1')rninsert into tree values ('3','0102','外语学院','1')rninsert into tree values ('4','02','B学校',null)rninsert into tree values ('5','0201','建筑学院','4')rninsert into tree values ('6','020101','城市规划','5')rninsert into tree values ('7','0202','土木工程学院','4')rngornrn我想写一个函数，只有参数 pidrn如果传入 null，则返回所以 idrn否则返回此pid的所有下级 idrnrn如传入 4rnrn则返回rn5rn6rn7rnrn返回table类型的，如果能用递归最好了

Problem DescriptionrnMr Cheng is a collector of old Chinese porcelain, more specifically late 15th century Feng dynasty vases. The art of vase-making at this time followed very strict artistic rules. There was a limited number of accepted styles, each defined by its shape and decoration. More specifically, there were 36 vase shapes and 36 different patterns of decoration – in all 1296 different styles.rnrnFor a collector, the obvious goal is to own a sample of each of the 1296 styles. Mr Cheng however, like so many other collectors, could never afford a complete collection, and instead concentrates on some shapes and some decorations. As symmetry between shape and decoration was one of thernmain aestheathical paradigms of the Feng dynasty, Mr Cheng wants to have a full collection of all combinations of k shapes and k decorations, for as large a k as possible. However, he has discovered that determining this k for a given collection is not always trivial. This means that his collection might actually be better than he thinks. Can you help him?rn rnrnInputrnOn the first line of the input, there is a single positive integer n, telling the number of test scenarios to follow. Each test scenario begins with a line containing a single positive integer m <=100 , the number of vases in the collection. Then follow m lines, one per vase, each with a pair of numbers, si and di, separated by a single space, where si ( 0 < i <= 36 ) indicates the shape of Mr Cheng's i:th vase, and di ( 0 < i <=36 ) indicates its decoration.rn rnrnOutputrnFor each test scenario, output one line containing the maximum k, such that there are k shapes and k decorations for which Mr Cheng's collection contains all k*k combined styles.rn rnrnSample Inputrn2rn5rn11 13rn23 5rn17 36rn11 5rn23 13rn2rn23 15rn15 23rn rnrnSample Outputrn2rn1
Cover
DescriptionnnGiven an N * N matrix A, whose elements are positive integers and not larger than 10000. There are also some '*'s in matrix A. Your program must find such three (perhaps overlapping) rectangles that they would contain all the '*'s which are in matrix A and the areas of these three rectangles (the area of one rectangle define as the number of elements it covers) must be non-negative and not exceed a given integer M. nnIf several solutions exist, the program should find a solution with minimal total costs of these three rectangles. The cost of one rectangle defines as the sum of all the numbers it contains in matrix A.nInputnnThe first line of the input is an integer X representing the number of test cases. The following X blocks each represents a test case. nnThe first line of each block contains two numbers N and M (1 <= N <= 30, 0 <= M <= N * N) representing the size of the matrix and the maximum area of each rectangle. The second line contains a number C (0 <= C <= N * N), representing the number of '*'s in matrix A. The following C lines each contains two numbers X and Y (1 <= X, Y <= N), representing A[X][Y] (A[X][Y] represents the element in the X-th row and Y-th column)contains a '*'. The following N lines each contains N numbers, representing the matrix A. nOutputnnFor each block output one line, which contains an integer representing the minimum total costs, or 'Impossible' (without quote) if no solution exists.nSample Inputnn5n1 1n0n9n1 1n1n1 1n9n5 6n5n1 1n3 4n4 3n4 5n5 4n5 3 1 1 1n3 1 1 1 1n1 1 1 2 1n1 1 2 5 2n1 1 1 2 1n5 3n5n1 1n3 4n4 3n4 5n5 4n5 3 1 1 1n3 1 1 1 1n1 1 1 2 1n1 1 2 5 2n1 1 1 2 1n5 2n4n1 1n3 4n4 3n4 5n5 3 1 1 1n3 1 1 1 1n1 1 1 2 1n1 1 2 5 2n1 1 1 2 1nSample Outputnn0n9n20n23nImpossible

C语言怎么用正则表达式？

设有5个哲学家,共享一张放油把椅子的桌子,每人分得一吧椅子.但是桌子上总共执友支筷子,在每个人两边分开各放一支.哲学家只有在肚子饥饿时才试图分两次从两边拾起筷子就餐.

3n+1问题 用c语言实现
Consider the following algorithm to generate a sequence of numbers.Start with an integer n.If n is even, divide by 2.If n is odd, multiply by 3 and add 1.Repeat this process with the new value of n

#include&amp;lt;stdio.h&amp;gt; #include&amp;lt;math.h&amp;gt; #include&amp;lt;stdlib.h&amp;gt; #define MAX 100 struct { int x,y; }zuobiao[MAX]; double zuijin() { int i,j,t; int d=100; int n=rand()%100+1; printf(...

Problem DescriptionrnLittle Ruins is a studious boy, recently he learned math!rnrnNow he defines f(k) equal the number of prime factors in k, and g(k)=2f(k), he want to knowrnrn∑i=1ng(i)rnrnrnPlease help him!rn rnrnInputrnFirst line contains an integer T, which indicates the number of test cases.rnrnEvery test case contains one line with one integer n.rnrnLimitsrn1≤T≤50.rn1≤n≤1012.rn rnrnOutputrnFor every test case, you should output 'Case #x: y', where x indicates the case number and counts from 1 and y is the result.rnrnBecause y could be very large, just mod it with 109+7.rn rnrnSample Inputrn3rn1rn10rn100rn rnrnSample OutputrnCase #1: 1rnCase #2: 23rnCase #3: 359

#include <stdio.h> #include <malloc.h> #define NULL 0 #include <iostream.h> typedef struct Lnode{ int data; struct Lnode *next; }joseph;

#include<stdio.h> #include<stdlib.h> #define M 6 #define N 8 #define MAXLEN 100 typedef struct { int x; int y; }item; typedef struct { int x; int y; int d; }dataType; typedef struct { dataType data[MAXLEN]; int top; }SeqStack; item move[8]; int maze[M+2][N+2]={ {1,1,1,1,1,1,1,1,1,1}, {1,0,1,1,1,0,1,1,1,1}, {1,1,0,1,0,1,1,1,1,1}, {1,0,1,0,0,0,0,0,1,1}, {1,0,1,1,1,0,1,1,1,1}, {1,1,0,0,1,1,0,0,0,1}, {1,0,1,1,0,0,1,1,0,1}, {1,1,1,1,1,1,1,1,1,1} };