This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 绘制几何体的形状,省略绘图代码 | |
// main.m | |
// Shape-Procedural | |
// | |
// Created by Novnan on 14-2-15. | |
// Copyright (c) 2014年 Novnan. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 输入一个字符串,存放在数组s1中,然后再输入一个字符串s2,在字符串s1中查找s2,并将找到的s2 | |
删除,重复这一过程,直到删除了s1中包含的所有s2,最后打印删除了所有s2的字符串s1 */ | |
#include <stdio.h> | |
#include <string.h> | |
void main() | |
{ | |
char s1[256], s2[256], s3[256]; | |
int i, j; | |
printf("输入字符串s1:"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 输入一个字符串,存放在字符数组中,然后将某个字符插入到该字符串的某个位置 | |
要求考虑输入的插入位置可能小于0(在首位插入),或大于字符串长度的情况(在尾部插入)等情况*/ | |
#include <stdio.h> | |
#include <string.h> | |
void main() | |
{ | |
char s[256]; | |
char ch; | |
int i, len, position; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 有近百名学生选修了某们课程,他们来源不同的专业班级,按班级,学号顺序打印学生的班级名称,学号和姓名。 | |
#include <stdio.h> | |
#include <string.h> | |
#define N 5 | |
#define LENGTH 10 | |
void s(); | |
void main() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"//": "Font", | |
"font_size": 12.0, | |
"//": "Indentation Settings", | |
"tab_size": 4, | |
"translate_tabs_to_spaces": true | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 用起泡法排序 | |
#include <stdio.h> | |
#define N 100 | |
void main() | |
{ | |
int iData[N]; | |
int *p; | |
int i, j, n, t; | |
printf("共有几个数(1~%d):", N); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 求二维数组iData[M][N]中最大元素所在的行和列 | |
#include <stdio.h> | |
#define M 3 | |
#define N 4 | |
void main() | |
{ | |
int i, j, iData[M][N]; | |
int *p, *pMax; | |
printf("请按行输入%d x %d数组的各元素:\n", M, N); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 某班有3名同学参加考试,求成绩最高的学生的姓名 | |
#include <stdio.h> | |
#define N 3 | |
void main() | |
{ | |
char sName[N][10]; // 只写sName[N]为什么不行 // 假设姓名最多占10个字符(最多4个汉子或9个字母) | |
int i, t, iScore[N]; | |
printf("顺序输入每个同学的姓名和成绩(用空格分开):\n"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 截取并输出任意字符串的前n个字符 | |
#include <stdio.h> | |
void main() | |
{ | |
char cData[256]; | |
char *p = cData; // *p指向字符数组cData | |
int n; | |
puts("请输入一串字符串:"); | |
gets(p); // 输入的字符串存放在数组cData中 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 求两个整数的最大公约数的算法; | |
对于两个整数integer1和integer2, 算法如下: | |
1 如果integer1/integer2的余数为0,那么integer2就是最大公约数 | |
2 如果余数不为0,那么将integer2赋值给integer1,余数赋值给integer2 | |
3 从步骤1重复执行 | |
编程一个程序来实现这个算法,它使用两个整型参数,并返回最大公约数。 */ | |
#include <stdio.h> |
NewerOlder