华为 10第二题 成都 约瑟夫环
http://blog.csdn.net/zy6778324/article/details/11708555
每套第三题貌似有点难度,先稍微休息下。
#include <stdio.h> #include <stdlib.h> struct Jose { int e; Jose *next; }Jose; int main() { int n,m; int i,j; struct Jose *head; struct Jose *q; //前一个 struct Jose *p; //当前 while(scanf("%d %d",&n,&m)!=EOF&&n>0&&m>0) { head = (struct Jose*)malloc(sizeof(struct Jose)); head->e = 1; // head->next = head; q = head; for(i=2;i<=n;i++) { p = (struct Jose*)malloc(sizeof(struct Jose)); p->e = i; // printf("%d---------",p->e); q->next = p; q = p; } q->next = head; p = head; for(i=n;i>1;i--) { for(j=1;j<m;j++) // { q = p; p = p ->next; } q->next = p->next; printf("%d---\n",p->e); free(p); p = q->next; } printf("%d",p->e); } return 0; }
每套第三题貌似有点难度,先稍微休息下。 #include #include struct Jose { int e; Jose *next; }Jose; int main() { int n,m; int i,j; struct Jose *head; struct Jose *q; //前一个 struct Jose *p; //当前 ...
#include int main() { char c; while(scanf("%c",&c)!=EOF) { if(c=='\n') continue; printf("%c\n",(c-'0'+'a')); } return 0; }...
#include #include int main() { char s1[130]; char s2[130]; char result[261]; int len1,len2; int i,j,k; while(scanf("%s %s",s1,s2)!=EOF) { printf("%s\n",s1); printf("%s\n",s2);...
#include #include #include int comp(const void *a,const void *b) { return *(char *)b - *(char *)a; } int main() { char in[200]; char pos[51]; char neg[51]; int len1; int i,k1,k...
大数乘法: #include #include using namespace std; #define N 999 class Mult { private: char result[N]; char *m1; char *m2; int len1; int len2; public: Mult(char *p1,char *p2,int a1,int...