1 #define _CRT_SECURE_NO_WARNINGS 1
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <math.h>
6 //文件类型的指针
7 int main()
8 {
9 FILE *fp = fopen("text.txt", "w");
10 fputc('A',fp);
11 system("pause");
12 return 0;
13 }
14
15
16 int main()
17 {
18 FILE *fp = NULL;
19 fp = fopen("text.txt", "w");
20 if (fp == NULL)
21 {
22 printf("打开失败\n");
23 return -1;
24 }
25 //输入字符串并进行转换
26 char ch;
27 while ((ch = getchar() != '!')&&(ch != EOF))
28 {
29 if (ch >= 'a'&&ch <= 'z')
30 {
31 ch -= 32;//小写转大写
32 }
33 fputc(ch, fp);
34 }
35 //关闭文件
36 fclose(fp);
37 system("pause");
38 return 0;
39 }
40
41
42
43 void OpenFile(FILE **fpa, FILE **fpb,FILE **fpc)
44 {
45 *fpa = fopen("4.txt", "r");
46 if (fpa == NULL)
47 {
48 printf("打开失败\n");
49 exit(1);
50 }
51 *fpb = fopen("4.txt", "r");
52 if (fpb == NULL)
53 {
54 printf("打开失败\n");
55 exit(1);
56 }
57 *fpc = fopen("4.txt", "r");
58 if (fpc == NULL)
59 {
60 printf("打开失败\n");
61 exit(1);
62 }
63 }
64 void GetBufferChar(FILE *fpa, FILE *fpb,char *buffer)
65 {
66 fgets(buffer, 1024, fpa);
67 int len = strlen(buffer);
68 fgets(buffer + len, 1024 - len, fpb);
69 }
70 void SortBufferChar(char *buffer)
71 {
72 //冒泡排序
73 int n = strlen(buffer);
74 for (int i = 0; i < n - 1; n++)
75 {
76 for (int j = 0; j < n - i - 1; ++j)
77 {
78 if (buffer[j]>buffer[j + 1])
79 {
80 int tmp = buffer[j];
81 buffer[j] = buffer[j + 1];
82 buffer[j + 1] = tmp;
83 }
84 }
85 }
86 }
87 void SaveFile(FILE *fpc, char *buffer)
88 {
89 fputs(buffer, fpc);
90
91 }
92 void CloseFile(FILE *fpa, FILE *fpb, FILE *fpc)
93 {
94 fclose(fpa);
95 fclose(fpb);
96 fclose(fpc);
97 }
98 void main()
99 {
100 FILE *fpa, *fpb, *fpc;
101 OpenFile(&fpa, &fpb, &fpc);
102 char buffer[1024] = { 0 };
103 GetBufferChar(fpa, fpb, buffer);
104 SortBufferChar(buffer);
105 SaveFile(fpc, buffer);
106 CloseFile(fpa, fpb, fpc);
107 system("pause");
108 }
109
110
111
112 typedef struct Student
113 {
114 int num;//学号
115 char name[32];//姓名
116 int score[3];//三门课程成绩
117 float avg;//三门课程平均分
118 }Student;
119 int main()
120 {
121 Student stu[5];//创建五个学生的结构体
122 for (int i = 0; i < 5; ++i)
123 {
124 printf("num name score1 score2 score3\n");
125 scanf("%d %s %d %d %d", &stu[i].num, stu[i].name, &stu[i].score[0], &stu[i].score[1], &stu[i].score[2]);
126 //计算平均分
127 stu[i].avg = (stu[i].score[0] + stu[i].score[1] + stu[i].score[2])/3.0;
128 }
129 FILE *fp = fopen("stud.txt", "w");
130 if (fp == NULL)
131 {
132 printf("打开文件失败\n");
133 return -1;
134 }
135 //将数据写入文件
136 for (int i = 0; i < 5; ++i)
137 {
138 fprintf(fp, "%d %s %d %d %d %f\n", stu[i].num, stu[i].name, stu[i].score[0], stu[i].score[1], stu[i].score[2],stu[i].avg);
139 }
140 fclose(fp);
141 system("pause");
142 return 0;
143 }
144
145
146
147
148 typedef struct Student
149 {
150 int num;//学号
151 char name[32];//姓名
152 int score[3];//三门课程成绩
153 float avg;//三门课程平均分
154 }Student;
155 void ReadData(Student *stu)
156 {
157 FILE *fp = fopen("stud.txt", "r");
158 if (fp == NULL)
159 {
160 printf("打开文件失败\n");
161 return -1;
162 }
163 //读入数据
164 for (int i = 0; i < 5; ++i)
165 {
166 fscanf("%d %s %d %d %d", &stu[i].num, stu[i].name, &stu[i].score[0], &stu[i].score[1], &stu[i].score[2]);
167 //计算平均分
168 stu[i].avg = (stu[i].score[0] + stu[i].score[1] + stu[i].score[2]) / 3.0;
169 }
170 //关闭文件
171 fclose(fp);
172 }
173 void SortData(Student *stu)
174 {
175 Student tmp_stu;
176 int size = sizeof(tmp_stu);
177 //冒泡排序
178 for (int i = 0; i < n - 1; ++i)
179 {
180 for (int j = 0; j < n - i - 1; ++j)
181 {
182 if (stu[j].avg < stu[j + 1].avg)
183 {
184 //交换结构体数据排序
185 memcpy(&tmp_stu, &stu[j], size);
186 memcpy(&stu[j], &stu[j + 1], size);
187 memcpy(&stu[j + 1], &tmp_stu, size);
188 }
189 }
190 }
191 }
192 void WriteData(Student *stu)
193 {
194 FILE *fp = fopen("stu_sort.txt", "w");
195 if (fp == NULL)
196 {
197 printf("打开文件失败\n");
198 return -1;
199 }
200 //写入数据
201 for (int i = 0; i < 5; ++i)
202 {
203 fprintf(fp, "%d %s %d %d %d %f\n", stu[i].num, stu[i].name, stu[i].score[0], stu[i].score[1], stu[i].score[2],stu[i].avg);
204 }
205 //关闭数据
206 fclose(fp);
207 }
208 int main()
209 {
210 Student stu[5];//创建五个学生的结构体
211 ReadData(stu);
212 SortData(stu,5);
213 WriteData(stu);
214 system("pause");
215 return 0;
216 }
217
218
219
220
221 typedef struct Student
222 {
223 int num;//学号
224 char name[32];//姓名
225 int score[3];//三门课程成绩
226 float avg;//三门课程平均分
227 }Student;
228 void InputData(Student *stu)
229 {
230 printf("请输入新学生的成绩信息:>\n");
231 printf("name score1 cscore2 score3 :\n");
232 scanf("%d %s %d %d %d", &(stu->num), stu->name, &(stu->score[0]), &(stu->score[1]), &(stu->score[2]));
233 stu->avg = (stu->score[0] + stu->score[1] + stu->score[2]) / 3.0;
234 }
235 void ReadData(Student **stu)
236 {
237 FILE *fp = fopen("stud.txt", "r");
238 if (fp == NULL)
239 {
240 printf("打开文件失败\n");
241 exit(-1);
242 }
243 //读入数据
244 for (int i = 0; i < 5; ++i)
245 {
246 fscanf("%d %s %d %d %d", &stu[i].num, stu[i].name, &stu[i].score[0], &stu[i].score[1], &stu[i].score[2]);
247 //计算平均分
248 stu[i].avg = (stu[i].score[0] + stu[i].score[1] + stu[i].score[2]) / 3.0;
249 }
250 //关闭文件
251 fclose(fp);
252 }
253 void InsertData(Student *old_stu,Student *new_stu,int n)
254 {
255 int pos = 0;
256 while (pos < n)
257 {
258 if (new_stu->avg>old_stu[pos].avg)
259 {
260 break;
261 }
262 pos++;
263 }
264 //移动数据
265 for (int i = n; i > pos; --i)
266 {
267 memcpy(&old_stu[i], &old_stu[i - 1], sizeof(Student));
268 }
269 //在pos位置把新学生的数据插入
270 memcpy(&old_stu[pos], new_stu, sizeof(Student));
271 }
272 void WriteData(Student *stu)
273 {
274 FILE *fp = fopen("stu_new_sort.txt", "w");
275 if (fp == NULL)
276 {
277 printf("打开文件失败\n");
278 exit(-1);
279 }
280 //写入数据
281 for (int i = 0; i < 6; ++i)
282 {
283 fprintf(fp, "%d %s %d %d %d %f\n", stu[i].num, stu[i].name, stu[i].score[0], stu[i].score[1], stu[i].score[2], stu[i].avg);
284 }
285 //关闭数据
286 fclose(fp);
287 }
288 int main()
289 {
290 Student new_stu;//新学生结构体
291 Student old_stu[6];
292 InputData(&new_stu);
293 ReadData(old_stu);
294 InsertData(&old_stu, &new_stu,5);
295 WriteData(old_stu);
296 system("pause");
297 return 0;
298 }
299
300
301
302 8.
303 typedef struct Student
304 {
305 int num;//学号
306 char name[32];//姓名
307 int score[3];//三门课程成绩
308 float avg;//三门课程平均分
309 }Student;
310 static count;
311 void InputData(Student *stu)
312 {
313 printf("请输入新学生的成绩信息:>\n");
314 printf("name score1 cscore2 score3 :\n");
315 scanf("%d %s %d %d %d", &(stu->num), stu->name, &(stu->score[0]), &(stu->score[1]), &(stu->score[2]));
316 stu->avg = (stu->score[0] + stu->score[1] + stu->score[2]) / 3.0;
317 }
318 void ReadData(Student **stu)
319 {
320 FILE *fp = fopen("stud.txt", "w");
321 if (fp == NULL)
322 {
323 printf("打开文件失败\n");
324 exit(-1);
325 }
326 //读出数据的条数
327 int count;
328 fscanf(fp, "%d\n", &count);
329 *stu = (Student*)malloc(sizeof(Student)*(count + 1));
330 Student *pstu = *stu;
331 //读入数据
332 for (int i = 0; i < count; ++i)
333 {
334 fscanf("%d %s %d %d %d", &pstu[i].num, pstu[i].name, &pstu[i].score[0], &pstu[i].score[1], &pstu[i].score[2]);
335 //计算平均分
336 pstu[i].avg = (pstu[i].score[0] + pstu[i].score[1] + pstu[i].score[2]) / 3.0;
337 }
338 //关闭文件
339 fclose(fp);
340 //释放空间,避免造成泄漏
341 free(stu);
342 }
343 void InsertData(Student *old_stu, Student *new_stu, int n)
344 {
345 int pos = 0;
346 while (pos < n)
347 {
348 if (new_stu->avg>old_stu[pos].avg)
349 {
350 break;
351 }
352 pos++;
353 }
354 //移动数据
355 for (int i = n; i > pos; --i)
356 {
357 memcpy(&old_stu[i], &old_stu[i - 1], sizeof(Student));
358 }
359 //在pos位置把新学生的数据插入
360 memcpy(&old_stu[pos], new_stu, sizeof(Student));
361 }
362 void WriteData(Student *stu)
363 {
364 FILE *fp = fopen("stu_new_sort.txt", "w");
365 if (fp == NULL)
366 {
367 printf("打开文件失败\n");
368 exit(-1);
369 }
370 //写入数据
371 fprintf(fp, "%d", count + 1);//先写出记录的条数
372 for (int i = 0; i < count+1; ++i)
373 {
374 fprintf(fp, "%d %s %d %d %d %f\n", stu[i].num, stu[i].name, stu[i].score[0], stu[i].score[1], stu[i].score[2], stu[i].avg);
375 }
376 //关闭数据
377 fclose(fp);
378
379 }
380 int main()
381 {
382 Student new_stu;//新学生结构体
383 Student old_stu[6];
384 InputData(&new_stu);
385 ReadData(&old_stu);
386 InsertData(&old_stu, &new_stu, count);
387 WriteData(old_stu);
388 system("pause");
389 return 0;
390 }
391
392
393 //9.
394 //employee.txt 读出数据
395 //抽出职工名字和工资
396 //输出到一个新的文件
397 typedef struct employee
398 {
399 int num;
400 char name[32];
401 char sex[4];
402 int age;
403 char addr[128];
404 int salary;
405 char health[10];
406 char classes[10];
407 }employee;
408 int main()
409 {
410 employee emp;
411 FILE *fpin = fopen("employee.txt", "w");
412 if (fpin == NULL)
413 {
414 printf("打开employee.txt文件失败\n");
415 return -1;
416 }
417 FILE *fpout = fopen("emp_salary.txt", "w");
418 if (fpout == NULL)
419 {
420 printf("打开emp_salary.txt文件失败\n");
421 fclose(fpin);
422 return -1;
423 }
424 //读出数据并抽出相应的信息进行写入
425 while (!feof(fpin))
426 {
427 int count = fscanf(fpin, "%d %s %s %d %s %d %s %s", &emp.num, emp.name, emp.sex, &emp.age, emp.addr, &emp.salary, emp.health, emp.classes);
428 if (count == -1)
429 {
430 break;
431 }
432 fprintf(fpout, "%s %d\n", emp.name, emp.salary);
433 }
434 //关闭文件
435 fclose(fpin);
436 fclose(fpout);
437 system("pause");
438 return 0;
439 }
440
441
442
443 //10.
444 //从程序里面输入一个名字,再进行查找需要删除的用户
445 typedef struct emp_salary
446 {
447 char name[32];
448 int salary;
449 }emp_salary;
450 int main()
451 {
452 emp_salary es[100];
453 FILE *fp = fopen("emp_salary.txt", "w");
454 if (fp == NULL)
455 {
456 printf("打开emp_salary.txt文件失败\n");
457 return -1;
458 }
459 int i = 0;
460 while (!feof(fp))
461 {
462 fscanf(fp, "%s %d", es[i].name, &es[i].salary);
463 if (count == 1)
464 {
465 break;
466 }
467 i++;
468 }
469 //关闭文件
470 fclose(fp);
471 //输入名字进行删除
472 char name[32] = { 0 };
473 printf("请输入要删除的职工的姓名:>");
474 scanf("%s", &name);
475 fp = fopen("emp_salary.txt", "w");
476 if (fp == NULL)
477 {
478 printf("打开emp_salary.txt文件失败\n");
479 return -1;
480 }
481 for (int j = 0; j < i; ++j)
482 {
483 if (strcmp(name, es[j].name) == 0)
484 {
485 continue;
486 }
487 fprintf(fp, "%s %d\n", es[j].name, es[j].salary);
488 }
489 //关闭文件
490 fclose(fp);
491 system("pause");
492 return 0;
493 }
494
495
496
497 11.
498 从键盘上输入若干个字符
499 存储到磁盘文件中
500 从文件中读入数据
501 将小写字母转成大写字母
502 输出到屏幕上
503 void ToUpper(char *str)
504 {
505 while (*str != '\0')
506 {
507 //小写字母
508 if (*str >= 'a'&&*str <= 'z')
509 {
510 *str -= 32;
511 }
512 //继续判断下一个字母
513 //直到所有判断完毕,退出程序
514 str++;
515 }
516 }
517 int main()
518 {
519 FILE *fp = fopen("letter.txt", "w");
520 if (fp == NULL)
521 {
522 printf("打开letter.txt文件失败\n");
523 return -1;
524 }
525 //输入字符串然后写入文件
526 char buf[128] = { 0 };
527 while (1)
528 {
529 printf("请输入字符串(如果输入exit则退出输入):>\n");
530 gets(buf);
531 if (strcmp("exit", buf) == 0)
532 {
533 break;
534 }
535 fprintf(fp, "%s\n", buf);
536 }
537 //关闭文件
538 fclose(fp);
539 //读出数据,进行转换
540 FILE *fp = fopen("letter.txt", "r");
541 if (fp == NULL)
542 {
543 printf("打开letter.txt文件失败\n");
544 return -1;
545 }
546 while (!feof(fp))
547 {
548 memset(buf, 0, 128);
549 fgets(buf, 128, fp);
550 ToUpper(buf);
551 printf("%s\n", buf);
552 }
553 //关闭文件
554 fclose(fp);
555 system("pause");
556 return 0;
557 }
558
559
560 int main()
561 {
562 int a;
563 printf("%d\n", a += a -= a = 9);
564 system("pause");
565 return 0;
566 }
567
568
569 int main()
570 {
571 int a = 1, b = 0;
572 if (!a)
573 {
574 b++;
575 }
576 else if (a == 0)
577 {
578 if (a) b += 2;
579 else b += 3;
580 }
581 printf("%d\n", b);//0
582 system("pause");
583 return 0;
584 }
585
586 int main()
587 {
588 int a = 1, b = 2;
589 while (a < 6)
590 {
591 b += a;
592 a += 2;
593 b %= 10;
594 }
595 printf("%d,%d\n", a, b);//7,1
596 system("pause");
597 return 0;
598 }
599
600
601 int main()
602 {
603 int y = 10;
604 while (y--)
605 {
606 printf("y=%d\n", y);
607 }
608 system("pause");//9 8 7 6 5 4 3 2 1 0
609 return 0;
610 }
611
612 int main()
613 {
614 char s[] = "rstuv";
615 printf("%c\n", *s + 2);
616 system("pause");
617 return 0;
618 }
619
620
621 int main()
622 {
623 char x[] = "STRING";
624 x[0] = 0;
625 x[1] = '\0';
626 x[2] = '0';
627 printf("%d %d\n", sizeof(x), strlen(x));//7 0
628 system("pause");
629 return 0;
630 }
631
632
633 int f(int x)
634 {
635 return x * 2;
636 }
637 int main()
638 {
639 int n = 1, m;
640 m = f(f(f(n)));
641 printf("%d\n", m);
642 system("pause");
643 return 0;
644 }
645
646
647 void f(int *p)
648 {
649 p = p + 3;
650 printf("%d,", *p);
651 }
652 int main()
653 {
654 int a[5] = { 1, 2, 3, 4, 5 }, *r = a;
655 f(r);
656 printf("%d\n", r);
657 system("pause");
658 return 0;
659 }
660
661
662 void fun(int *a, int n)
663 {
664 int i, j, k, t;
665 for (i = 0; i < n; i += 2)
666 {
667 k = i;
668 for (j = 1; j < n-1; j += 2)
669 {
670 if (a[j]>a[k]) k = j;
671 }
672 t = a[i];
673 a[i] = a[k];
674 a[k] = t;
675 }
676 }
677 int main()
678 {
679 int aa[10] = { 1, 2, 3, 4, 5, 6, 7 }, a;
680 fun(aa, 7);
681 for (int i = 0; i < 7; i++)
682 {
683 printf("%d,", aa[i]);
684 }
685 printf("\n");
686 system("pause");
687 return 0;
688 }
689
690
691 int main()
692 {
693 char a[20] = "ABCD\0'EFG\0'";
694 char b[] = "IJK";
695 strcat(a, b);
696 printf("%s\n", a);
697 system("pause");
698 return 0;
699 }
700
701
702
703 #include <ctype.h>
704 void fun(char *p)
705 {
706 int i = 0;
707 while (p[i])
708 {
709 if (p[i] = ' '&&islower(p[i - 1]))
710 {
711 p[i - 1] = p[i - 1] - 'a' + 'A';
712 }
713 i++;
714 }
715 }
716 int main()
717 {
718 char s1[100] = "ab cd EFG!";
719 fun(s1);
720 printf("%s\n", s1);
721 system("pause");
722 return 0;
723 }
724
725
726 void fun(int x)
727 {
728 if (x / 2 > 1) fun(x / 2);
729 printf("%d ", x);
730 }
731 int main()
732 {
733 fun(7);
734 printf("\n");
735 system("pause");
736 return 0;
737 }
738
739
740 int fun()
741 {
742 static int x = 1;
743 x += 1;
744 return x;
745 }
746 int main()
747 {
748 int i, s = 1;
749 for (i = 1; i <= 5; i++)
750 {
751 s += fun();
752 }
753 printf("%d\n", s);
754 system("pause");
755 return 0;
756 }
757
758 int main()
759 {
760 int *a, *b, *c;
761 a = b = c = (int *)malloc(sizeof(int));
762 *a = 1; *b = 2; *c = 3;
763 a = b;
764 printf("%d,%d,%d\n", *a, *b, *c);
765 system("pause");
766 return 0;
767 }
768
769 int main()
770 {
771 int s, t, A = 10;
772 double B = 6;
773 s = sizeof(A);
774 t = sizeof(B);
775 printf("%d,%d\n", s, t);
776 system("pause");
777 return 0;
778 }
779
780 int main()
781 {
782 int x = 12;
783 double y = 3.141593;
784 printf("%d%8.6f\n", x, y);
785 system("pause");
786 return 0;
787 }
788
789 int main()
790 {
791 int x = 2;
792 printf("%d\n", 2*x,x+=2);
793 system("pause");
794 return 0;
795 }
796
797
798 #define I 20
799 #define R 340
800 int main()
801 {
802 system("mode con cols=80 lines=60 ");
803 system("title 向你致以最诚挚的祝福!");
804 char data[200][60] = { { "祝你生日快乐!祝你生日快乐 !" }, { "\nHappy birthday to you!\n" }};
805 int sign = 0;
806 int i, j, e;
807 int a;
808 long time;
809 for (i = 1, a = I; i<I/2;i++,a--)
810 {
811
812 for (j = (int)(I - sqrt(I*I - (a - i)*(a - i))); j>0; j--)
813 printf(" ");
814 for (e = 1; e <= 2 * sqrt(I*I - (a - i)*(a - i)); e++)
815 printf("\3");
816 for (j = (int)
817 (2 * (I - sqrt(I*I - (a - i)*(a - i)))); j>0; j--)
818 printf(" ");
819 for (e = 1; e <= 2 * sqrt(I*I - (a - i)*(a - i)); e++)
820 printf("\3");
821 printf("\n");
822 }
823 for (i = 1; i<80; i++)
824
825 {
826 if (i == 25)
827 {
828 printf("======小黑弟,生日快乐。======");
829 i += 30;
830 }
831 printf("\3");
832 }
833 printf("\n");
834 for (i = 1; i <= R / 2; i++)
835 {
836 if (i % 2 || i % 3)
837 continue;
838 for (j = (int)(R - sqrt(R*R - i*i)); j>0; j--)
839 printf(" ");
840 for (e = 1; e <= 2 * (sqrt(R*R - i*i) - (R - 2 * I)); e++)
841 printf("\3");
842 printf("\n");
843 }
844 /*for (;;)
845 {
846 system("color a");
847 for (time = 0; time<99999999; time++); system("color b");
848 for (time = 0; time<99999999; time++); system("color c");
849 for (time = 0; time<99999999; time++); system("color d");
850 for (time = 0; time<99999999; time++); system("color e");
851 for (time = 0; time<99999999; time++); system("color f");
852 for (time = 0; time<99999999; time++);
853 system("color 0"); for (time = 0; time<99999999; time++);
854 system("color 1"); for (time = 0; time<99999999; time++);
855 system("color 2"); for (time = 0; time<99999999; time++);
856 system("color 3"); for (time = 0; time<99999999; time++);
857 system("color 4");
858 for (time = 0; time<99999999; time++); system("color 5");
859 for (time = 0; time<99999999; time++); system("color 6");
860 for (time = 0; time<99999999; time++); system("color 7");
861 for (time = 0; time<99999999; time++); system("color 8");
862 for (time = 0; time<99999999; time++); system("color 9");
863 for (time = 0; time<99999999; time++); system("color ab");
864 for (time = 0; time<99999999; time++); system("color ac");
865 for (time = 0; time<99999999; time++); system("color ad");
866 for (time = 0; time<99999999; time++); system("color ae");
867 for (time = 0; time<99999999; time++); system("color af");
868 for (time = 0; time<99999999; time++);
869 printf("%s", data[sign]);
870 sign++;
871 }*/
872 system("pause");
873 return 0;
874 }
875
876 #include <Windows.h>
877 #include <conio.h>
878 #define N 100//产生随即颜色
879 char randk(){//产生随即颜色
880 char a = 0;
881 a = (char)abs(rand() % 16);
882 if (a >= 10){
883 a -= 10;
884 a += 97;
885 }
886 else a += 48;
887
888 return a;
889 }
890 extern char s_1[] = { "我为你收集了编程所有的美,放在你生日的烛台上。将能说的话都藏在花蕾里,让它成为待放的秘密。" };
891 extern char s_2[] = { "一碗甜甜的长寿面,筋斗的面条是我长长的祝愿,一丝丝将你缠绕到永远,愿健康与快乐、幸福和甜蜜与你日夜相伴,祝你生日快乐!" };
892 extern char s_3[] = { "愿我的心是一朵鲜花,盛开在你的天空下,为你的生日增添一点温馨的情调,为你的快乐增添一片美丽的光华!" };
893 extern char s_4[] = { "在这个值得庆贺的日子里,我虽无鲜花与美酒献礼,但心中有歌,谨祝你一生快乐。" };
894 extern char s_5[] = { "绿色是生命的颜色,绿色的浪漫是生命的浪漫。因此,我选择了这个绿色的世界,馈赠给你的生日。愿你充满活力,青春常在。" };
895 extern char s_6[] = { "当吹生日蜡烛的时候我许下心愿,当流星划过天际的时候我许下心愿,当写这个程序的时候我也许下心愿:愿正在看这个程序的人一生幸福快乐!" };
896 extern char s_7[] = { "你用优美的年轮编成一册散发油墨清香的日历,年年我都会在日历的这一页上用深情的想念祝福你的生日!" };
897 extern char s_8[] = { "在你生日的这一天,将快乐的音符,作为礼物送给你,愿您拥有365个美丽的日子,衷心地祝福你--生日快乐!" };
898 extern char s_9[] = { "一生中总有一些朋友难忘记;一年中总有一些日子最珍惜;从春走到冬;由陌生转为熟悉;虽不能时时问候;在特别的日子里祝你生日快乐!" };
899 extern char s_10[] = { "只有懂得生活的人,才能领略鲜花的娇艳,只有懂得爱的人,才能领略到心中芬芳,祝你有一个特别的生日。" };
900 extern char s_11[] = { "日月轮转永不断,情若真挚长相伴,不论你身在天涯海角,我将永远记住这一天。祝你生日快乐!" };
901 extern char s_12[] = { "在这个充满喜悦的日子里,衷心祝愿您青春长驻,愿将一份宁静和喜悦悄悄带给您,生日快乐!" };
902 extern char s_13[] = { "幸福、愉快、欢乐都由你的生日而来,我把至诚的祝福化成一个美丽的谜,带到你的生日宴会上来,让你猜……" };
903 extern char s_14[] = { "喂!老友,今天是你的大生日!在这个时刻,我要送给你千万个嘱咐与问候,这是最值钱的\"寒酸\"!" };
904 extern char s_15[] = { "两片绿叶,饱含着它同根生的情谊;一句贺词,浓缩了我对你的祝福。愿快乐拥抱你,在这属于你的特别的一天,生日快乐!" };
905 extern char s_16[] = { "祈望你心灵深处--芳草永绿,青春常驻,笑口常开。祝你生日快乐幸福!\n" };
906 extern char s_17[] = { " 祝你幸福!\n" };
907 extern char s_18[] = { " " };
908 extern char s_19[] = { " 2022-3-25" };
909 extern char * ssum[] = { s_1, s_2, s_3, s_4, s_5, s_6, s_7, s_8, s_9, s_10, s_11, s_12, s_13, s_14, s_15, s_16, s_17, s_18, s_19 };
910 void main(){
911 system("title 生日贺卡");
912 int i = 0;
913 long f = 0;
914 char s[10] = "color ";
915 puts("\n\n\n\n\n\n\n\n\n\n ");
916 for (i = 0; i<N; i++){//要变色的次数
917 s[6] = randk(); s[7] = randk();
918 system(s);//调用cmd的color命令
919 printf("\r★Happy Birthday!★★Happy Birthday!★★Happy Birthday!★★Happy Birthday!★★Happy Birthday!★★Happy Birthday!★★Happy Birthday!★");
920 f = 0;
921 while (f<81474400)f = f + 1;
922 }
923 puts("小黑弟:\n\n\n");
924 s[6] = 'e';//背景为d淡红色
925 //输出要说的话
926 for (i = 0; i<19; i++){//为要输出的行数
927 puts("\n\a");
928 s[7] = randk();
929 system(s);//调用cmd的color命
930 puts(*(ssum + i));
931 f = 0;
932 while (f<214748325){
933 f = f + 1;
934 f = f - 1;
935 f = f + 1;
936 }
937 }
938 getchar();
939 }
940
941
942 int main()
943 {
944 int x = 011;
945 printf("%d\n", ++x);
946 system("pause");
947 return 0;
948 }
949
950 int main()
951 {
952 int s;
953 scanf("%d", &s);
954 while (s > 0)
955 {
956 switch (s)
957 {
958 case 1:printf("%d", s + 5);
959 case 2:printf("%d", s + 4); break;
960 case 3:printf("%d", s + 3);
961 default:printf("%d", s + 1); break;
962 }
963 scanf("%d", &s);
964 }
965 system("pause");
966 return 0;
967 }
968
969 int main()
970 {
971 int i, n;
972 for (i = 0; i < 8; i++)
973 {
974 n = rand() % 5;
975 switch (n)
976 {
977 case 1:
978 case 3:printf("%d\n", n); break;
979 case 2:
980 case 4:printf("%d\n", n); continue;
981 case 0:exit(0);
982 }
983 printf("%d\n", n);
984 }
985 system("pause");
986 return 0;
987 }
988
989 int main()
990 {
991 char s[] = "012xy\08s34f4w2";
992 int i, n = 0;
993 for (i = 0; s[i] != 0; i++)
994 {
995 if (s[i] >= '0'&&s[i] <= '9') n++;
996 }
997 printf("%d\n", n);
998 system("pause");
999 return 0;
1000 }
1001
1002 int main()
1003 {
1004 for (int i = 0, k = -1; k = 1; k++)
1005 {
1006 printf("*****\n");
1007 }
1008 system("pause");
1009 return 0;
1010 }
1011
1012 int main()
1013 {
1014 char b, c; int i;
1015 b = 'a'; c = 'A';
1016 for (i = 0; i < 6; i++)
1017 {
1018 if (i % 2) putchar(i + b);
1019 else putchar(i + c);
1020 }
1021 printf("\n");
1022 system("pause");
1023 return 0;
1024 }
1025
1026 void Fun(char *s)
1027 {
1028 while (*s)
1029 {
1030 if (*s % 2) printf("%c", *s);
1031 s++;
1032 }
1033 }
1034 int main()
1035 {
1036 char s[] = "BYTE";
1037 Fun(s);
1038 printf("\n");
1039 system("pause");
1040 return 0;
1041 }
1042
1043 int main()
1044 {
1045 int x = 1, y = 0;
1046 if (!x)
1047 {
1048 y++;
1049 }
1050 else if (x == 0)
1051 {
1052 if (x) y += 2;
1053 else y += 3;
1054 }
1055 printf("%d\n", y);
1056 system("pause");
1057 return 0;
1058 }