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 ;
}

转载于:https://www.cnblogs.com/donneyming/archive/2010/04/15/1712480.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值