请将此C ++代码转换为C. [英] please convert this C++ code to C

查看:106
本文介绍了请将此C ++代码转换为C.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include<bits/std++.h>
#define ll long long int
#define ld long double
#define ite iterator
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define ioS ios::sync_with_stdio(false);
#define fr(i,x,n) for(int i=x;i<n;i++)>
#define re0 return 0 ;
#define mod 1000000007
using namespace std ;

ll  n,i,j,md,hi,lo ,mx,h,k,flag,sum,x,t,y,w,ans,q,hsh  ;
int main()
{
    cin >> t ;
    while(t--){
    string s;
    flag= 0 ;
    cin >> s;
     mx = 0;
   string::iterator itr1,itr2;

    for(itr1 = s.begin(); itr1 != s.end(); ++itr1)
        for( itr2 = itr1 + 1; itr2 != s.end(); ++itr2)
            mx = max(mx,(ll)(mismatch(itr1, itr1 + (s.end() - itr2), itr2).ff - itr1));
    if(flag==0)cout << mx << endl ;
    else cout << "0\n" ;
}
}

推荐答案

基本上,替换cin>> with scanf,cout<<使用printf,并删除命名空间。该字符串将是一个字符数组。并且你必须将循环编码为没有开始或结束的循环的正常。



但说实话,它可能不完全是你的导师想要,反正它也不会是好的c代码。如果你忽略了你找到的地方并自己编写,你会得到更好的成绩...从长远来看也可能更容易......
Basically, replace the cin >> with scanf, cout << with printf, and delete the namespace. The string will be an array of characters. and you will have to code the loops as "normal" for loops without the begin or end.

But to be honest, it probably doesn't do exactly what your tutor wants, and it won't be "good" c code anyway. You'll get a better grade if you ignore the place you found that and write your own... probably be easier in the long run as well...


这篇关于请将此C ++代码转换为C.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆