• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
donneyming
博客园    首页    新随笔    联系   管理    订阅  订阅
c和指针的第一个程序 哈哈
 

 

#include "iostream"

using namespace std;

#define  MAX 10
#define  LEN 50

char strraw[MAX*2+1];
int  a[MAX][2];
char str[MAX][LEN];
int count = 0;
int strcount = 0;

int getsplitarr(FILE*  fs);

int getstrarr(FILE* fs);

int showstrarr();

static void convert(const char* array);
static void showlog(const int arr[][2],int len,int wei);

int main()
{
getsplitarr(stdin);

convert(strraw);
//showlog(a,MAX,2);
getstrarr(stdin);

showstrarr();
return 0;
}

int getsplitarr(FILE*  fs)
{
if (fs == NULL)
{
return -1;
}

fgets(strraw,MAX*LEN,fs);
  return 0;
}


 int getstrarr(FILE* fs)
 {
char c = 'a';
if (fs == NULL)
{
return -1;
}
while (fgets(str[strcount],LEN,fs) != NULL) 
{
// fgets(str[strcount],LEN,fs);
// c = getchar();

if (str[strcount][0] == 10)
{
break;
}
strcount ++;
}
  return 0;
 }

int showstrarr()
{
int len = 0;

for (int i =0;i<strcount;i++)
{
len = strlen(str[i]);
cout<<"before converse:"<<str[i]<<endl;

cout<<"after converse:";

for (int j=0 ;j <count; j++)
{
if (len <a[j][0])
{
break;
}

else if ((len >= a[j][0]) && (len <= a[j][1]))
{
for (int k= a[j][0] ;k<= len-1; k++)
cout<<str[i][k];
}
else
{
for (int k= a[j][0] ;k<= a[j][1]; k++)
cout<<str[i][k];
}

}
cout<<endl;
}

return 0;
}

static void convert(const char* array)
{
int size = strlen(array);

for (int i =0;i<size;i++)
{
if (array[i] == 45 || array[i] == 10) //结束符号 注:45 :-1;10:回车符
{
break;
}
if (array[i] == 32)//32空格键
{
continue;
}


if (a[count][0] == 0)
{
a[count][0] = array[i] - '0';
}
else if (a[count][1] == 0)
{
a[count][1] = array[i] - '0';
}

if ((a[count][0] * a[count][1]) >0)
{
count =count +1;
}
}
return;
}

static void showlog(const int arr[][2],int len,int wei)
{
for (int i=0;i<len;i++)
{
for (int j=0;j<wei;j++)
{
cout<<arr[i][j];
}

cout<<endl;
}

return ;
}
posted on 2010-04-15 11:29  donneyming  阅读(256)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3